Skip to content
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

HDDS-11990. Use arity in decommission subcommands #7618

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

adoroszlai
Copy link
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 sodonnel and smengcl January 2, 2025 12:44
Copy link
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

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. tools Tools that helps with debugging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants