-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-12596: remove --zookeeper option from topic command #10457
Conversation
@ijuma @tombentley , could you help review this PR? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Maybe we can remove the TopicService
trait and rename AdminClientTopicService
to TopicService
? Do we use the trait for anything now that the ZK code was removed?
private val reportAtMinIsrPartitionsOpt = parser.accepts("at-min-isr-partitions", | ||
"if set when describing topics, only show partitions whose isr count is equal to the configured minimum. Not supported with the --zookeeper option.") | ||
"if set when describing topics, only show partitions whose isr count is equal to the configured minimum.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this line:
// This is not currently used, but we keep it for compatibility
parser.accepts("force", "Suppress console prompts")
Was this deprecated also? Can we remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed this issue is fixed in KIP-74 (KAFKA-2063). Yes I'll remove it!. Thank you.
if (!has(bootstrapServerOpt)) | ||
CommandLineUtils.checkRequiredArgs(parser, options, zkConnectOpt) | ||
throw new IllegalArgumentException("--bootstrap-server must be specified") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can mark the argument as required to get this behavior automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion! Updated
if(has(describeOpt) && has(ifExistsOpt)) | ||
CommandLineUtils.checkRequiredArgs(parser, options, topicOpt) | ||
if (!has(listOpt) && !has(describeOpt)) | ||
CommandLineUtils.checkRequiredArgs(parser, options, topicOpt) | ||
if (has(createOpt) && !has(replicaAssignmentOpt) && has(zkConnectOpt)) | ||
if (has(createOpt) && !has(replicaAssignmentOpt)) | ||
CommandLineUtils.checkRequiredArgs(parser, options, partitionsOpt, replicationFactorOpt) | ||
if (has(bootstrapServerOpt) && has(alterOpt)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need the has(bootstrapServerOpt)
check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right.
} | ||
|
||
case class AdminClientTopicService private (adminClient: Admin) extends TopicService { | ||
case class TopicService private (adminClient: Admin) extends AutoCloseable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename AdminClientTopicService
into TopicService
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be a case class.
@@ -204,23 +196,7 @@ object TopicCommand extends Logging { | |||
} | |||
} | |||
|
|||
trait TopicService extends AutoCloseable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove TopicService
trait since we only have one service now.
.withRequiredArg | ||
.describedAs("server to connect to") | ||
.ofType(classOf[String]) | ||
.required() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set as required argument.
@@ -98,15 +100,15 @@ class TopicCommandWithAdminClientTest extends KafkaServerTestHarness with Loggin | |||
@Test | |||
def testCreate(): Unit = { | |||
createAndWaitTopic(new TopicCommandOptions( | |||
Array("--partitions", "2", "--replication-factor", "1", "--topic", testTopicName))) | |||
brokerOptions ++ Array("--partitions", "2", "--replication-factor", "1", "--topic", testTopicName))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't checkArgs
before, so it's ok to not pass the --bootstrap-server
option. Since we make it as required argument now, we need to pass the option explicitly.
@ijuma , thanks for the good suggestion. Yes, we don't need the |
@@ -65,9 +65,10 @@ class TopicCommandWithAdminClientTest extends KafkaServerTestHarness with Loggin | |||
private val numPartitions = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can rename this test to be TopicCommandTest
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ijuma , we already have a TopicCommandTest
to do Unit test. This TopicCommandWithAdminClientTest
is much like an integration test. How about rename to TopicCommandIntegrationTest
just like DeleteOffsetsConsumerGroupCommandIntegrationTest
in the same folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I rename the test to TopicCommandIntegrationTest
, and move this test to integration test folder: core/src/test/scala/integration/kafka/admin
. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name sounds good, but I think you don't have to move the test. We rely on tags instead of directory structure for distinguishing test types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Moved back now. Thanks.
@ijuma , I've updated the PR to check |
@ijuma , could you please check this PR? Thank you.
|
@ijuma , please help review this PR again. Thanks. |
failed tests are unrelated and flaky. Thanks.
|
core/src/test/scala/unit/kafka/admin/TopicCommandIntegrationTest.scala
Outdated
Show resolved
Hide resolved
CommandLineUtils.checkRequiredArgs(parser, options, topicOpt) | ||
if (!has(listOpt) && !has(describeOpt)) | ||
CommandLineUtils.checkRequiredArgs(parser, options, topicOpt) | ||
if (has(createOpt) && !has(replicaAssignmentOpt) && has(zkConnectOpt)) | ||
if (has(createOpt) && !has(replicaAssignmentOpt)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it a bug that we only verified this when zkConnectOpt
was set? If so, we should add a unit test for this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Added 2 tests: testCreateWithAssignmentAndPartitionCount
and testCreateWithAssignmentAndReplicationFactor
in TopicCommandTest
. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. Just a few comments, I think we're close.
@ijuma , Thanks for the comments. I've updated. Please take a look again. Thank you very much. |
Failed tests are unrelated and flaky. Thanks.
|
@ijuma , could you help check this PR again? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, LGTM.
Unrelated failures:
|
After merging, I noticed we are missing a note in upgrade.html. We can fix that as part of #10471. |
One more thing, did we check that there are no system tests using the flag we just removed? |
Will address the above 2 comments in #10471. Thank you. |
[KIP-464](https://cwiki.apache.org/confluence/display/KAFKA/KIP-464%3A+Defaults+for+AdminClient%23createTopic) (PR: #6728) made it possible to create topics without passing partition count and/or replica factor when using the admin client. We incorrectly disallowed this via #10457 while trying to ensure validation was consistent between ZK and the admin client (in this case the inconsistency was intentional). Fix this regression and add tests for the command lines in quick start (i.e. create topic and describe topic) to make sure it won't be broken in the future. Reviewers: Lee Dongjin <[email protected]>, Ismael Juma <[email protected]>
[KIP-464](https://cwiki.apache.org/confluence/display/KAFKA/KIP-464%3A+Defaults+for+AdminClient%23createTopic) (PR: #6728) made it possible to create topics without passing partition count and/or replica factor when using the admin client. We incorrectly disallowed this via #10457 while trying to ensure validation was consistent between ZK and the admin client (in this case the inconsistency was intentional). Fix this regression and add tests for the command lines in quick start (i.e. create topic and describe topic) to make sure it won't be broken in the future. Reviewers: Lee Dongjin <[email protected]>, Ismael Juma <[email protected]>
[KIP-464](https://cwiki.apache.org/confluence/display/KAFKA/KIP-464%3A+Defaults+for+AdminClient%23createTopic) (PR: #6728) made it possible to create topics without passing partition count and/or replica factor when using the admin client. We incorrectly disallowed this via #10457 while trying to ensure validation was consistent between ZK and the admin client (in this case the inconsistency was intentional). Fix this regression and add tests for the command lines in quick start (i.e. create topic and describe topic) to make sure it won't be broken in the future. Reviewers: Lee Dongjin <[email protected]>, Ismael Juma <[email protected]>
[KIP-464](https://cwiki.apache.org/confluence/display/KAFKA/KIP-464%3A+Defaults+for+AdminClient%23createTopic) (PR: apache/kafka#6728) made it possible to create topics without passing partition count and/or replica factor when using the admin client. We incorrectly disallowed this via apache/kafka#10457 while trying to ensure validation was consistent between ZK and the admin client (in this case the inconsistency was intentional). Fix this regression and add tests for the command lines in quick start (i.e. create topic and describe topic) to make sure it won't be broken in the future. Reviewers: Lee Dongjin <[email protected]>, Ismael Juma <[email protected]>
…he#11429) [KIP-464](https://cwiki.apache.org/confluence/display/KAFKA/KIP-464%3A+Defaults+for+AdminClient%23createTopic) (PR: apache#6728) made it possible to create topics without passing partition count and/or replica factor when using the admin client. We incorrectly disallowed this via apache#10457 while trying to ensure validation was consistent between ZK and the admin client (in this case the inconsistency was intentional). Fix this regression and add tests for the command lines in quick start (i.e. create topic and describe topic) to make sure it won't be broken in the future. Reviewers: Lee Dongjin <[email protected]>, Ismael Juma <[email protected]>
…he#11429) [KIP-464](https://cwiki.apache.org/confluence/display/KAFKA/KIP-464%3A+Defaults+for+AdminClient%23createTopic) (PR: apache#6728) made it possible to create topics without passing partition count and/or replica factor when using the admin client. We incorrectly disallowed this via apache#10457 while trying to ensure validation was consistent between ZK and the admin client (in this case the inconsistency was intentional). Fix this regression and add tests for the command lines in quick start (i.e. create topic and describe topic) to make sure it won't be broken in the future. Reviewers: Lee Dongjin <[email protected]>, Ismael Juma <[email protected]>
Remove
ZookeeperTopicService
and the test using zookeeperTopicCommandWithZKClientTest
Committer Checklist (excluded from commit message)