[
https://issues.apache.org/jira/browse/HDFS-17809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18063943#comment-18063943
]
ASF GitHub Bot commented on HDFS-17809:
---------------------------------------
balodesecurity opened a new pull request, #8324:
URL: https://github.com/apache/hadoop/pull/8324
## Summary
`hdfs diskbalancer -help plan` (and `-help execute`, `-help query`, `-help
cancel`, `-help report`) always printed the generic usage summary instead of
the per-command help text. This is a regression compared to Hadoop 3.1.1.
### Root Cause
The `--help` option is declared with `.optionalArg(true)` in Apache Commons
CLI. With that flag, the option value is **only** captured when the equals-sign
form is used (`--help=plan`). A space-separated form (`-help plan`) leaves
`plan` as a positional leftover argument, so `cmd.getOptionValue("help")`
returns `null` and `HelpCommand` falls through to printing generic help.
### Fix
In `HelpCommand.execute()`, after `getOptionValue("help")` returns null,
fall back to the first element of `cmd.getArgs()` as the sub-command name. This
makes the natural `hdfs diskbalancer -help <cmd>` syntax work without requiring
the awkward `--help=<cmd>` form.
### Changes
- `HelpCommand.java`: add fallback to `cmd.getArgs()[0]` when the option
value is null.
- `TestDiskBalancerCommand.java`: add `testHelpCommandWithSubCommand` which
runs `-help <cmd>` for all five sub-commands and asserts the output contains
the expected keyword.
## Test plan
- [ ] `TestDiskBalancerCommand#testHelpCommandWithSubCommand` passes locally
✅
- [ ] Full module build passes (`mvn package ... -DskipTests`) ✅
- [ ] Existing `testHelpCommand` (no sub-command) still passes ✅
> hdfs diskbalancer -help plan or other commands are not giving correct
> explanation in hadoop version 3.4.1
> ---------------------------------------------------------------------------------------------------------
>
> Key: HDFS-17809
> URL: https://issues.apache.org/jira/browse/HDFS-17809
> Project: Hadoop HDFS
> Issue Type: Bug
> Components: diskbalancer
> Affects Versions: 3.4.1
> Reporter: Raju Balpande
> Priority: Major
>
> For HDFS with hadoop version 3.4.1, facing problem in help for diskbalancer
> commands.
> {code:java}
> [[email protected] ~]# hdfs diskbalancer -help query
> usage: hdfs diskbalancer [command] [options]DiskBalancer distributes data
> evenly between different disks on a
> datanode. DiskBalancer operates by generating a plan, that tells datanode
> how to move data between disks. Users can execute a plan by submitting it
> to the datanode.
> To get specific help on a particular command please run hdfs diskbalancer
> -help <command>.
> --help valid commands are plan | execute | query | cancel | report
> {code}
> I tried similar for all the commands l{*}ike plan, execute, report{*} and
> getting same response as if it is ignoring any text after help. Also tried
> with *--help* as well.
> {code:java}
> [[email protected] ~]# hdfs diskbalancer --help
> execute
> usage: hdfs diskbalancer [command] [options]DiskBalancer distributes data
> evenly between different disks on a
> datanode. DiskBalancer operates by generating a plan, that tells datanode
> how to move data between disks. Users can execute a plan by submitting it
> to the datanode.
> To get specific help on a particular command please run hdfs diskbalancer
> -help <command>.
> --help valid commands are plan | execute | query | cancel | report
> {code}
> Whereas the same commands works fine in *Hadoop version 3.1.1*
> {code:java}
> [[email protected] ~]# hdfs diskbalancer -help query
> usage: hdfs diskbalancer -query <hostname> [options]
> Query Plan queries a given data node about the current state of disk
> balancer execution.
> --query <arg> Queries the disk balancer status of a given datanode.
> --v Prints details of the plan that is being executed on
> the node.Query command retrievs the plan ID and the
> current running state. {code}
> Can someone please look into this.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]