Skip to content

HDDS-11990. Use arity in decommission subcommands#7618

Merged
adoroszlai merged 3 commits intoapache:masterfrom
adoroszlai:HDDS-11990
Jan 3, 2025
Merged

HDDS-11990. Use arity in decommission subcommands#7618
adoroszlai merged 3 commits intoapache:masterfrom
adoroszlai:HDDS-11990

Conversation

@adoroszlai
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Reduce code duplication in decommission and maintenance subcommands.

  • Specify arity to require at least one parameter, instead of checking explicitly.
  • Extract duplicated "list of host names" parameter and logic.
  • Reuse "show errors" logic.

https://issues.apache.org/jira/browse/HDDS-11990

How was this patch tested?

Tested in ozone-topology env:

$ ozone admin datanode maintenance
Missing required parameter: '<host name>'
Usage: ozone admin datanode maintenance [-hV] [--force] [--end=<endInHours>]
                                        [-id=<scmServiceId>] [--scm=<scm>]
                                        <host name>...
Put a datanode into Maintenance Mode
      <host name>...       One or more host names separated by spaces. To read
                             from stdin, specify '-' and supply the host names
                             separated by newlines.
      --end=<endInHours>   Automatically end maintenance after the given hours.
                             By default, maintenance must be ended manually.
      --force              Forcefully try to decommission the datanode(s)
  -h, --help               Show this help message and exit.
      -id, --service-id=<scmServiceId>
                           ServiceId of SCM HA Cluster
      --scm=<scm>          The destination scm (host:port)
  -V, --version            Print version information and exit.


$ ozone admin datanode maintenance - <<EOF
> 18f367dac6f6
> 2f5e52c1f56b
> EOF
Entering maintenance mode on datanode(s):
18f367dac6f6
2f5e52c1f56b


$ ozone admin datanode maintenance asdf
Entering maintenance mode on datanode(s):
asdf
Error: asdf: asdf: Name or service not known
Some nodes could not start the maintenance workflow

@adoroszlai adoroszlai added tools Tools that helps with debugging code-cleanup Changes that aim to make code better, without changing functionality. labels Dec 26, 2024
@adoroszlai adoroszlai self-assigned this Dec 26, 2024
@adoroszlai adoroszlai requested review from smengcl and sodonnel January 2, 2025 12:44
Copy link
Copy Markdown
Contributor

@smengcl smengcl left a comment

Choose a reason for hiding this comment

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

lgtm. Thanks @adoroszlai for the improvement

@adoroszlai adoroszlai merged commit bf112aa into apache:master Jan 3, 2025
@adoroszlai adoroszlai deleted the HDDS-11990 branch January 3, 2025 07:57
@adoroszlai
Copy link
Copy Markdown
Contributor Author

Thanks @smengcl for the review.

@adoroszlai adoroszlai added command-line and removed tools Tools that helps with debugging labels Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-cleanup Changes that aim to make code better, without changing functionality. command-line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants