Skip to content

Conversation

jack2012aa
Copy link
Contributor

@jack2012aa jack2012aa commented Sep 30, 2025

Description

In kafka-features.sh, exclusive argument group of --bootstrap-server
and --bootstrap-controller is required in the main parser, but
version-mapping and feature-dependencies subcommands don't need the
information.

Changes

To avoid change in argument level, the exclusive group is not moved. It
is now not required and only check for existence if the subcommand needs
it.

Since FeatureCommand#mainNoExit catches ArgumentParserException,
ArgumentParser#parseArgs is used instead of parseArgsOrFail. It
makes testing easier.

Two tests are added. One tests whether not-remote subcommand can execute
without bootstrap. Another tests whether remote subcommand cannot
execute without bootstrap.

Reviewers: Ken Huang [email protected], Jhen-Yung Hsu
[email protected], TaiJuWu [email protected], Chia-Ping Tsai
[email protected]

@github-actions github-actions bot added triage PRs from the community tools small Small PRs labels Sep 30, 2025
@jack2012aa jack2012aa changed the title Kafka 19749 The version-mapping of kafka-features.sh should work without requiring the bootstrap KAFKA-19749 The version-mapping of kafka-features.sh should work without requiring the bootstrap Sep 30, 2025
Copy link
Collaborator

@Yunyung Yunyung left a comment

Choose a reason for hiding this comment

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

LGTM.

@jack2012aa
Copy link
Contributor Author

LGTM.

Thanks for the review!

Copy link
Collaborator

@m1a2st m1a2st left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@github-actions github-actions bot removed the triage PRs from the community label Oct 1, 2025
Copy link
Collaborator

@TaiJuWu TaiJuWu left a comment

Choose a reason for hiding this comment

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

LGTM.

Comment on lines 112 to 114
// bootstrap_server and bootstrap_controller are in a mutually exclusive group,
// so the exception happens only when both of them are missing
throw new ArgumentParserException("one of the arguments --bootstrap-server --bootstrap-controller is required", parser);
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about new ArgumentParserException(e.getMessage(), parser)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! Yes, it's better to use the existing message rather than write a new one. The code has been updated.

Namespace namespace = parser.parseArgsOrFail(args);
Namespace namespace = parser.parseArgs(args);
String command = namespace.getString("command");
if (command.equals("version-mapping")) {
Copy link
Member

Choose a reason for hiding this comment

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

This approach allows version-mapping to be used with both bootstrap-server and bootstrap-controller, which seems a bit odd to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The version-mapping and feature-dependencies subcommands don't use bootstrap-server and bootstrap-controller arguments at all. The best practice is to let these arguments be required arguments of other subcommands. But I am not sure whether this change will require an KIP or worth one. Do you have any suggestion?

Or, we can check whether user uses these arguments with version-mapping and feature-dependencies, which makes the code more ugly but can provide user more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants