HDFS-17809. hdfs diskbalancer -help <command> shows only generic help.#8324
Open
balodesecurity wants to merge 1 commit intoapache:trunkfrom
Open
HDFS-17809. hdfs diskbalancer -help <command> shows only generic help.#8324balodesecurity wants to merge 1 commit intoapache:trunkfrom
balodesecurity wants to merge 1 commit intoapache:trunkfrom
Conversation
With Apache Commons CLI's optionalArg(true), a space-separated argument
after the option name (e.g. -help plan) is NOT captured as the option's
value — only the equals-sign form (--help=plan) works. As a result,
cmd.getOptionValue("help") always returned null and HelpCommand printed
the generic usage summary instead of the per-command details.
Fix: after getOptionValue("help") returns null, fall back to
cmd.getArgs()[0] (the first positional leftover) as the sub-command name.
This makes "-help plan", "-help execute", "-help query", "-help cancel",
and "-help report" all display the correct command-specific help text.
Test: TestDiskBalancerCommand#testHelpCommandWithSubCommand iterates all
five sub-commands and asserts the output contains the sub-command keyword.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
💔 -1 overall
This message was automatically generated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
--helpoption 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) leavesplanas a positional leftover argument, socmd.getOptionValue("help")returnsnullandHelpCommandfalls through to printing generic help.Fix
In
HelpCommand.execute(), aftergetOptionValue("help")returns null, fall back to the first element ofcmd.getArgs()as the sub-command name. This makes the naturalhdfs diskbalancer -help <cmd>syntax work without requiring the awkward--help=<cmd>form.Changes
HelpCommand.java: add fallback tocmd.getArgs()[0]when the option value is null.TestDiskBalancerCommand.java: addtestHelpCommandWithSubCommandwhich runs-help <cmd>for all five sub-commands and asserts the output contains the expected keyword.Test plan
TestDiskBalancerCommand#testHelpCommandWithSubCommandpasses locally ✅mvn package ... -DskipTests) ✅testHelpCommand(no sub-command) still passes ✅