KAFKA-13689: Optimized the printing of AbstractConfig logs, and stripped unknownKeys from unusedKeys#11800
Conversation
… cpu and traffic on the broker side increase sharply JIRA link : https://issues.apache.org/jira/browse/KAFKA-13310 Author: RivenSun2 <riven.sun@zoom.us> Reviewers: Luke Chen <showuon@gmail.com>
…sets method JIRA link : https://issues.apache.org/jira/browse/KAFKA-13310 Author: RivenSun2 <riven.sun@zoom.us> Reviewers: Luke Chen <showuon@gmail.com>
2. Optimize the import of package Author: RivenSun2 <riven.sun@zoom.us> Reviewers: Luke Chen <showuon@gmail.com>
Author: RivenSun2 <riven.sun@zoom.us> Reviewers: Luke Chen <showuon@gmail.com>
Author: RivenSun2 <riven.sun@zoom.us> Reviewers: Luke Chen <showuon@gmail.com>
Author: RivenSun2 <riven.sun@zoom.us> Reviewers: Luke Chen <showuon@gmail.com>
Author: RivenSun2 <riven.sun@zoom.us> Reviewers: Luke Chen <showuon@gmail.com>
add test Method "testForceMetadataDeleteForPatternSubscriptionDuringRebalance()" Author: RivenSun2 <riven.sun@zoom.us> Reviewers: Luke Chen <showuon@gmail.com>
Author: RivenSun2 <riven.sun@zoom.us> Reviewers: Luke Chen <showuon@gmail.com>
Author: RivenSun2 riven.sun@zoom.us
� Conflicts: � clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java
…ped unknownKeys from unusedKeys
|
Hi @showuon @guozhangwang |
showuon
left a comment
There was a problem hiding this comment.
@RivenSun2 , thanks for the PR. Left some comments.
| for (String key : unused()) | ||
| Set<String> unusedKeys = unused(); | ||
| //Printing unusedKeys to users should remove unknownKeys | ||
| unusedKeys.removeAll(unknown()); |
There was a problem hiding this comment.
Could we move this remove unknown keys into unUsed method, and let logUnused only do the log thing?
There was a problem hiding this comment.
I don't want to change the existing behavior of unused() method, otherwise many testCases in AbstractConfigTest will fail.
Only when printing unusedKeys to the user, tell the user exactly which configurations are known but unused
There was a problem hiding this comment.
For KafkaClient, unknownKeys also belong to unusedKeys, what do you think?
There was a problem hiding this comment.
Before this PR, the unUsed set contains both unUsed and unKnown configs, because we didn't separate them.
After this PR, we hope we can separate the unUsed and unKnown, so we created a new method unKnown. Under this situation, I don't think it makes sense to make unUsed set contains both unUsed and unKnown. That will just confuse other developers.
There was a problem hiding this comment.
ok, I agree with you.
| props.put(unknownTestConfig, "my_value"); | ||
| ConsumerConfig config = new ConsumerConfig(ConsumerConfig.appendDeserializerToConfig(props, new StringDeserializer(), new StringDeserializer())); | ||
|
|
||
| assertTrue(config.unknown().contains(unknownTestConfig)); |
There was a problem hiding this comment.
I think we should also verify the config.unknown() has only 1 element, that is: unknownTestConfig. In current verification, there could be many unknown in the configs, but still pass the test. Same as below.
There was a problem hiding this comment.
I agree with you,thanks.
| } | ||
|
|
||
| @Test | ||
| public void testUnknownConfigs() { |
There was a problem hiding this comment.
I think we should also test the mix of unknown and unused configs case, because we have some logic for them, right?
There was a problem hiding this comment.
In fact, I don't recommend changing the current logic of the unused method, because for KafkaClient, unknownKeys also belong to unusedKeys, what do you think?
There was a problem hiding this comment.
I think we can add the mix of unknown and unused test case, no matter we want to change unused logics or not. That is, like the previous testUnusedConfigs test, we can add an unknown configs into it, and verify the unUsed and unknown results are as what we expected.
| config.logUnused(); | ||
| config.logUnknown(); |
There was a problem hiding this comment.
It's a little weird and easy to forget to call these 2 methods after client initialization. Could we create a public logUnknownAndUnused method, and make both logUnused and logUnknown as private, so that users will always call logUnknownAndUnused to log both. WDYT?
|
@showuon |
|
@showuon |
showuon
left a comment
There was a problem hiding this comment.
@RivenSun2 , thanks for the update. Left some comments.
|
|
||
| assertTrue(config.unused().contains(SslConfigs.SSL_PROTOCOL_CONFIG)); | ||
| assertTrue(config.unknown().contains(unknownTestConfig)); | ||
| assertEquals(1, config.unknown().size()); |
There was a problem hiding this comment.
We should also assert the unUsed().size() == 1.
There was a problem hiding this comment.
In fact, unused.size is not 1, I will add assert for it later.
| assertTrue(config.unused().contains("sasl.mechanism")); | ||
| assertEquals("GSSAPI", valuesWithPrefixOverride.get("sasl.mechanism")); | ||
| assertFalse(config.unused().contains("sasl.mechanism")); | ||
| assertFalse(config.unused().contains("prefix.sasl.mechanism")); |
There was a problem hiding this comment.
here, we should change to assert unknown, right?
Same as below.
There was a problem hiding this comment.
Should we add
assertFalse(config.unknown().contains("prefix.sasl.mechanism"));
here? Because we assert unknown before using prefix.sasl.mechanism config (i.e. valuesWithPrefixOverride.get("sasl.mechanism")), we should expect prefix.sasl.mechanism is not unknown after using it, right?
showuon
left a comment
There was a problem hiding this comment.
Thanks for the update. Left some comments.
| assertEquals(1, config.unknown().size()); | ||
| assertEquals(3, config.unused().size()); |
There was a problem hiding this comment.
I these assert here is not meaningful. We can remove them and keep the asserts after consumer created below.
| assertTrue(config.unused().contains(SslConfigs.SSL_PROTOCOL_CONFIG)); | ||
| assertTrue(config.unknown().contains(unknownTestConfig)); | ||
| assertEquals(1, config.unknown().size()); | ||
| assertEquals(4, config.unused().size()); |
There was a problem hiding this comment.
Same here, we can just keep the asserts after consumer created
| assertEquals(1, config.unknown().size()); | ||
| assertEquals(3, config.unused().size()); |
| assertTrue(config.unused().contains("sasl.mechanism")); | ||
| assertEquals("GSSAPI", valuesWithPrefixOverride.get("sasl.mechanism")); | ||
| assertFalse(config.unused().contains("sasl.mechanism")); | ||
| assertFalse(config.unused().contains("prefix.sasl.mechanism")); |
There was a problem hiding this comment.
Should we add
assertFalse(config.unknown().contains("prefix.sasl.mechanism"));
here? Because we assert unknown before using prefix.sasl.mechanism config (i.e. valuesWithPrefixOverride.get("sasl.mechanism")), we should expect prefix.sasl.mechanism is not unknown after using it, right?
| assertFalse(config.unused().contains("sasl.kerberos.kinit.cmd")); | ||
| assertEquals("/usr/bin/kinit2", valuesWithPrefixOverride.get("sasl.kerberos.kinit.cmd")); | ||
| assertFalse(config.unused().contains("sasl.kerberos.kinit.cmd")); | ||
| assertFalse(config.unused().contains("prefix.sasl.kerberos.kinit.cmd")); |
There was a problem hiding this comment.
same here and below, we should assert false to (config.unknown().contains("prefix.sasl.kerberos.kinit.cmd") after using that config.
|
Hi @showuon Thank you for your reply. |
@RivenSun2 , are you saying there will be some configs that are not in |
|
@showuon
|
|
In fact, in the testcases we discussed in The main purpose of these testCases is to test whether the Map value returned by AbstractConfig#valuesWithPrefixOverride meets our expectations under different conditions. Thanks. |
Thanks for the explanation. But I don't think it is correct. If we check the original test below in // prefix overrides global
assertTrue(config.unused().contains("prefix.sasl.mechanism"));
assertTrue(config.unused().contains("sasl.mechanism"));
assertEquals("GSSAPI", valuesWithPrefixOverride.get("sasl.mechanism"));
assertFalse(config.unused().contains("sasl.mechanism"));
assertFalse(config.unused().contains("prefix.sasl.mechanism"));We can see the Theh, we should change the last assert to assert unknown there: Does that make sense? |
|
@showuon However, after |
So, could we also remove Thanks. |
|
Hi @showuon
|
Yes, this is what I expected. Thanks.
In the above test case, we originally expect that |
|
@showuon I totally agree with you now. It was I forgot to modify a code that caused it to not meet our expectations.
What do you think? |
|
Or we add an instance variable In this way, in the |
The reason we call |
|
@showuon |
That looks good, but I think that doesn't work in some cases, like the Thanks. |
|
@showuon |
showuon
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the PR! I'll wait for another week to see if there are other people also want to have a review. Thanks.
|
@RivenSun2 , thanks for the contribution! |
| log.info(b.toString()); | ||
| } | ||
|
|
||
| public void logUnusedAndUnknown() { |
There was a problem hiding this comment.
This class is public and hence a kip is required for this https://javadoc.io/doc/org.apache.kafka/kafka-clients/latest/org/apache/kafka/common/config/AbstractConfig.html
There was a problem hiding this comment.
Oh... Thanks for the reminder. @RivenSun2 , could you summit a small KIP for this change? Thanks.
There was a problem hiding this comment.
Did we consider the fact that we don't know the config names for pluggable components?
There was a problem hiding this comment.
TBH, no, I've never considered that! Thanks for the reminder.
@RivenSun2 , sorry, I forgot the AbstractConfig is a public API. But since the v3.2.0 KIP freeze has passed, and I think this KIP might need more discussion, could you submit another PR to revert this change first? After KIP discussion/voting passed, we can start to work on it again. If you don't have time to submit a revert PR within this week, please let me know. Thank you.
|
Hi @showuon |
|
@RivenSun2 , thanks for the help.
Let's start with
Something like KIP-519. Let's discuss it in KIP discussion. Thanks. Thank you. |
Optimized the printing of AbstractConfig logs, and stripped unknownKeys from unusedKeys