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-11837. Support executing multiple commands in Ozone CLI #7727

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

Conversation

adoroszlai
Copy link
Contributor

What changes were proposed in this pull request?

Support batch mode in Ozone CLI subcommands which already have --interactive mode enabled, by adding repeatable --execute <cmd> option.

This allows running multiple commands with the same invocation, like:

ozone sh \
  --execute 'volume create /vol1' \
  --execute 'bucket create /vol1/bucket1'

Update Robot tests to utilize batch mode in few test cases.

(Initially I wanted to use input redirection. It is still supported, but Robot tests are not great with here-docs.)

Also fix a warning from TailTipWidgets when running without TTY.

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

How was this patch tested?

CI:
https://github.com/adoroszlai/ozone/actions/runs/12871125080

@adoroszlai adoroszlai self-assigned this Jan 20, 2025
@sodonnel
Copy link
Contributor

This looks very useful. A couple of questions:

  1. If one command in a batch fails, what happens? Do the others keep executing or does it stop the batch?
  2. What if commands have output? Does each command output just goto stdout / stderr? Is there any delimiter to indicate the start / end of an output, or what command the output is associated with?

@adoroszlai
Copy link
Contributor Author

adoroszlai commented Jan 22, 2025

  1. If one command in a batch fails, what happens? Do the others keep executing or does it stop the batch?

Yes, it keeps executing. The behavior is inherited from interactive shell, where this is desired. I guess batch mode should stop on first error.

  1. What if commands have output? Does each command output just goto stdout / stderr? Is there any delimiter to indicate the start / end of an output, or what command the output is associated with?

Commands are echoed, so it's easy to see which command resulted in which output.

$ ozone sh \
  --execute 'volume create /x' \
  --execute 'volume create /vol3' \
  --execute 'bucket create /vol3/bucket1' \
  --execute 'key put /vol3/bucket1/key /etc/hostname' \
  --execute 'key cat /vol3/bucket1/key'
volume create /x
INVALID_VOLUME_NAME volume length is illegal, valid length is 3-63 characters
volume create /vol3
VOLUME_ALREADY_EXISTS Volume already exists
bucket create /vol3/bucket1
BUCKET_ALREADY_EXISTS Bucket already exist
key put /vol3/bucket1/key /etc/hostname
key cat /vol3/bucket1/key
9e574fae0cca

@sodonnel
Copy link
Contributor

I guess batch mode should stop on first error.

Yea, I think that makes sense, as often subsequent commands depend on earlier ones, or might have unexpected results if the earlier one failed.

Probably makes sense to stop after the first failure, and then have a zero access status for the entire interactive command if all worked, or a non-zero on any failure and then halt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants