Skip to content
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

Merged
merged 9 commits into from
Jun 1, 2021

Conversation

showuon
Copy link
Contributor

@showuon showuon commented Apr 1, 2021

Remove ZookeeperTopicService and the test using zookeeper TopicCommandWithZKClientTest

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@showuon
Copy link
Contributor Author

showuon commented Apr 1, 2021

@ijuma @tombentley , could you help review this PR? Thanks.

Copy link
Member

@ijuma ijuma left a 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.")
Copy link
Member

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?

Copy link
Contributor Author

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")
Copy link
Member

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.

Copy link
Contributor Author

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)) {
Copy link
Member

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.

Copy link
Contributor Author

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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename AdminClientTopicService into TopicService

Copy link
Member

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 {
Copy link
Contributor Author

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()
Copy link
Contributor Author

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)))
Copy link
Contributor Author

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.

@showuon
Copy link
Contributor Author

showuon commented Apr 2, 2021

@ijuma , thanks for the good suggestion. Yes, we don't need the TopicService trait now. Updated. Please help review it again. Thank you.

@@ -65,9 +65,10 @@ class TopicCommandWithAdminClientTest extends KafkaServerTestHarness with Loggin
private val numPartitions = 1
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@showuon showuon changed the title KAFKA-12588: remove --zookeeper option from topic command KAFKA-12596: remove --zookeeper option from topic command Apr 4, 2021
@showuon
Copy link
Contributor Author

showuon commented Apr 7, 2021

@ijuma , I've updated the PR to check --bootstrap-server option manually, so that the help text can print without arguments. Thanks.

@showuon
Copy link
Contributor Author

showuon commented Apr 16, 2021

@ijuma , could you please check this PR? Thank you.
Failed tests are all un-related.

    Build / JDK 15 and Scala 2.13 / kafka.server.RaftClusterTest.testCreateClusterAndCreateAndManyTopicsWithManyPartitions()
    Build / JDK 8 and Scala 2.12 / kafka.admin.ReassignPartitionsIntegrationTest.testLogDirReassignment()

@showuon
Copy link
Contributor Author

showuon commented May 18, 2021

@ijuma , please help review this PR again. Thanks.

@showuon
Copy link
Contributor Author

showuon commented May 18, 2021

failed tests are unrelated and flaky. Thanks.

    Build / JDK 15 and Scala 2.13 / org.apache.kafka.connect.integration.BlockingConnectorTest.testBlockInSinkTaskStart
    Build / JDK 15 and Scala 2.13 / org.apache.kafka.connect.integration.BlockingConnectorTest.testBlockInConnectorStop
    Build / JDK 11 and Scala 2.13 / org.apache.kafka.connect.integration.SourceConnectorsIntegrationTest.testTopicsAreCreatedWhenAutoCreateTopicsIsEnabledAtTheBroker
    Build / JDK 11 and Scala 2.13 / kafka.integration.MetricsDuringTopicCreationDeletionTest.testMetricsDuringTopicCreateDelete()

@ijuma ijuma added the kraft label May 19, 2021
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))
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@ijuma ijuma left a 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.

@showuon
Copy link
Contributor Author

showuon commented May 20, 2021

@ijuma , Thanks for the comments. I've updated. Please take a look again. Thank you very much.

@showuon
Copy link
Contributor Author

showuon commented May 20, 2021

Failed tests are unrelated and flaky. Thanks.

    Build / JDK 8 and Scala 2.12 / org.apache.kafka.connect.mirror.integration.MirrorConnectorsIntegrationSSLTest.testReplicationWithEmptyPartition()
    Build / JDK 11 and Scala 2.13 / kafka.server.RaftClusterTest.testCreateClusterAndCreateListDeleteTopic()
    Build / JDK 15 and Scala 2.13 / org.apache.kafka.connect.mirror.integration.MirrorConnectorsIntegrationTest.testReplication()

@showuon
Copy link
Contributor Author

showuon commented Jun 1, 2021

@ijuma , could you help check this PR again? Thanks.

Copy link
Member

@ijuma ijuma left a 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.

@ijuma
Copy link
Member

ijuma commented Jun 1, 2021

Unrelated failures:

Build / JDK 8 and Scala 2.12 / testReplicationWithEmptyPartition() – org.apache.kafka.connect.mirror.integration.MirrorConnectorsIntegrationSSLTest
4s
Build / JDK 11 and Scala 2.13 / testCreateClusterAndCreateListDeleteTopic() – kafka.server.RaftClusterTest
15s
Build / JDK 15 and Scala 2.13 / testReplication() – org.apache.kafka.connect.mirror.integration.MirrorConnectorsIntegrationTest

@ijuma ijuma merged commit 21532a7 into apache:trunk Jun 1, 2021
@ijuma
Copy link
Member

ijuma commented Jun 1, 2021

After merging, I noticed we are missing a note in upgrade.html. We can fix that as part of #10471.

@ijuma
Copy link
Member

ijuma commented Jun 1, 2021

One more thing, did we check that there are no system tests using the flag we just removed?

@showuon
Copy link
Contributor Author

showuon commented Jun 2, 2021

Will address the above 2 comments in #10471. Thank you.

@showuon showuon deleted the KAFKA-12596 branch June 2, 2021 10:03
ijuma pushed a commit that referenced this pull request Nov 4, 2021
[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]>
ijuma pushed a commit that referenced this pull request Nov 4, 2021
[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]>
ijuma pushed a commit that referenced this pull request Nov 4, 2021
[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]>
a0x8o added a commit to a0x8o/kafka that referenced this pull request Nov 5, 2021
[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]>
xdgrulez pushed a commit to xdgrulez/kafka that referenced this pull request Dec 22, 2021
…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]>
lmr3796 pushed a commit to lmr3796/kafka that referenced this pull request Jun 2, 2022
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants