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

Action: Task exit code #13132

Merged
merged 5 commits into from Jul 5, 2021
Merged

Conversation

SimonRichardson
Copy link
Member

The following propagates the task result exit code up to the CLI so that
a user calling juju exec will know that an error occurred in one or
more tasks. Prior to this commit, users would have to inspect every
result which is a bit disappointing for bash style scripting against the
CLI. With this change it should be possible to do the following:

$ juju exec --all 'exit 1'
$ echo $? # should see 1

This makes juju a lot more powerful to sys or ops users.

The code is simple, inspect the result for an exit code. If it exists
propagate it to the CLI and return an error stating the fact that a task
failed.

QA steps

$ juju bootstrap lxd test
$ juju exec -m controller 'exit 1'

The following propagates the task result exit code up to the CLI so that
a user calling `juju exec` will know that an error occurred in one or
more tasks. Prior to this commit, users would have to inspect every
result which is a bit disappointing for bash style scripting against the
CLI. With this change it should be possible to do the following:

   $ juju exec --all 'exit 1'
   $ echo $? # should see 1

This makes juju a lot more powerful to sys or ops users.

The code is simple, inspect the result for an exit code. If it exists
propagate it to the CLI and return an error stating the fact that a task
failed.
The wait-for type isn't used any more, so let's just remove it.
The following updates the error message to identify the task failure and
the return code of the failure.
cmd/juju/action/common.go Show resolved Hide resolved
cmd/juju/action/common.go Show resolved Hide resolved
cmd/juju/action/exec_test.go Show resolved Hide resolved
cmd/juju/action/common.go Show resolved Hide resolved
Give hints about where to go next if there was a failure. This just
improves juju usability.
@SimonRichardson
Copy link
Member Author

$$merge$$

@jujubot jujubot merged commit 76d529c into juju:develop Jul 5, 2021
@SimonRichardson SimonRichardson deleted the action-exit-code branch July 5, 2021 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants