-
Notifications
You must be signed in to change notification settings - Fork 14.7k
KAFKA-19749 The version-mapping
of kafka-features.sh should work without requiring the bootstrap
#20619
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
base: trunk
Are you sure you want to change the base?
KAFKA-19749 The version-mapping
of kafka-features.sh should work without requiring the bootstrap
#20619
Changes from 3 commits
63dac7d
3940027
c8ccf23
d6679a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ static void execute(String... args) throws Exception { | |
.newArgumentParser("kafka-features") | ||
.defaultHelp(true) | ||
.description("This tool manages feature flags in Kafka."); | ||
MutuallyExclusiveGroup bootstrapGroup = parser.addMutuallyExclusiveGroup().required(true); | ||
MutuallyExclusiveGroup bootstrapGroup = parser.addMutuallyExclusiveGroup(); | ||
bootstrapGroup.addArgument("--bootstrap-server") | ||
.help("A comma-separated list of host:port pairs to use for establishing the connection to the Kafka cluster."); | ||
bootstrapGroup.addArgument("--bootstrap-controller") | ||
|
@@ -92,14 +92,27 @@ static void execute(String... args) throws Exception { | |
addVersionMappingParser(subparsers); | ||
addFeatureDependenciesParser(subparsers); | ||
|
||
Namespace namespace = parser.parseArgsOrFail(args); | ||
Namespace namespace = parser.parseArgs(args); | ||
String command = namespace.getString("command"); | ||
if (command.equals("version-mapping")) { | ||
handleVersionMapping(namespace, Feature.PRODUCTION_FEATURES); | ||
return; | ||
} else if (command.equals("feature-dependencies")) { | ||
handleFeatureDependencies(namespace, Feature.PRODUCTION_FEATURES); | ||
return; | ||
} | ||
String configPath = namespace.getString("command_config"); | ||
Properties properties = (configPath == null) ? new Properties() : Utils.loadProps(configPath); | ||
|
||
CommandLineUtils.initializeBootstrapProperties(properties, | ||
Optional.ofNullable(namespace.getString("bootstrap_server")), | ||
Optional.ofNullable(namespace.getString("bootstrap_controller"))); | ||
try { | ||
CommandLineUtils.initializeBootstrapProperties(properties, | ||
Optional.ofNullable(namespace.getString("bootstrap_server")), | ||
Optional.ofNullable(namespace.getString("bootstrap_controller"))); | ||
} catch (Exception e) { | ||
// 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); | ||
|
||
} | ||
|
||
try (Admin adminClient = Admin.create(properties)) { | ||
switch (command) { | ||
|
@@ -115,12 +128,6 @@ static void execute(String... args) throws Exception { | |
case "disable": | ||
handleDisable(namespace, adminClient); | ||
break; | ||
case "version-mapping": | ||
handleVersionMapping(namespace, Feature.PRODUCTION_FEATURES); | ||
break; | ||
case "feature-dependencies": | ||
handleFeatureDependencies(namespace, Feature.PRODUCTION_FEATURES); | ||
break; | ||
default: | ||
throw new TerseException("Unknown command " + command); | ||
} | ||
|
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 approach allows
version-mapping
to be used with bothbootstrap-server
andbootstrap-controller
, which seems a bit odd to meThere 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
version-mapping
andfeature-dependencies
subcommands don't usebootstrap-server
andbootstrap-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
andfeature-dependencies
, which makes the code more ugly but can provide user more information.