HDDS-15558. Add CLI option style annotation processor - #10891
Conversation
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @F64116045 for the patch, it works fine. I have two concerns:
- New top-level commands need to be added to this test, which is easy to miss.
- (minor) Violations in mixins are reported for each usage.
I think both could be addressed by implementing it as an annotation processor for @Option.
|
Thanks @adoroszlai for the suggestion! Updated the patch to use an annotation processor. |
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @F64116045 for updating the patch.
Verified that offending options are reported correctly:
[ERROR] hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/ShellReplicationOptions.java:[27,58] CLI option '--repli_cation_type' uses a deprecated style. New options should use --dash-separated-style long names or single-character short names.
[ERROR] hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/bucket/ListBucketHandler.java:[49,50] CLI option '-snap' uses a deprecated style. New options should use --dash-separated-style long names or single-character short names.
| // Keep this in sync with DeprecatedCliOption in hdds-cli-common. This module | ||
| // cannot depend on CLI common, as CLI common runs this processor at compile | ||
| // time. | ||
| private static final Set<String> KNOWN_DEPRECATED_OPTIONS = |
There was a problem hiding this comment.
We can remove KNOWN_DEPRECATED_OPTIONS and isKnownDeprecatedOption, since deprecated options are expected to be hidden, which is achieved by handling them programmatically, not in @Option(names) (see HDDS-15596).
Removing this reveals that some explicit usage of known deprecated options was introduced on the HDDS-8342-ttl-branch feature branch, recently merged to master. We can remove these:
--- hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/LifecycleResumeSubCommand.java
+++ hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/LifecycleResumeSubCommand.java
@@ -38,13 +38,13 @@ public class LifecycleResumeSubCommand implements Callable<Void> {
private LifecycleSubCommand parent;
@CommandLine.Option(
- names = {"-id", "--service-id"},
+ names = {"--service-id"},
description = "Ozone Manager Service ID"
)
private String omServiceId;
@CommandLine.Option(
- names = {"-host", "--service-host"},
+ names = {"--service-host"},
description = "Ozone Manager Host"
)
private String omHost;and also from:
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/LifecycleStatusSubCommand.java
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/LifecycleSuspendSubCommand.java
There was a problem hiding this comment.
Thanks for clarifying this! I updated the patch and verified the related modules compile successfully.
|
Thanks @F64116045 for the patch. |
What changes were proposed in this pull request?
This patch adds a compile-time annotation processor to validate picocli
@Optionnames used by Ozone CLI commands.The processor rejects new options that use deprecated styles, including multi-character short options, camelCase long options, and under_score long options. Existing deprecated option aliases are allowlisted so current commands continue to compile.
The processor is wired into the modules that currently declare CLI options, so option style is checked during compilation.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15558
How was this patch tested?
Result:
BUILD SUCCESSCI: https://github.com/F64116045/ozone/actions/runs/30504192230