juju run-action --wait return code should (optionally) reflect the success/failure of the action

Bug #1892887 reported by James Troup
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
Wishlist
Unassigned

Bug Description

juju run-action should have a way for its return code to reflect the success or failure of the action itself. Arguably (and IMO) this should be the default but it could instead be done by means of an option to run-action.

This (combined with --wait) would allow one to chain together actions in a powerful and idiomatically UNIX way, e.g.

  juju run-action --wait $UNIT pause && juju run-action --wait $UNIT upgrade && juju run-action --wait $UNIT upgrade

Revision history for this message
Ian Booth (wallyworld) wrote :

run-action currently creates an "operation" which is the parent for the individual tasks, each task being an invocation of an action on a unit.

We could special case the situation where there's only one target and hence one task.

Changed in juju:
milestone: none → 2.9-beta1
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Pen Gale (pengale) wrote :

I think that it would make sense to exit 0 if all the subtasks exited 0, and pick one of the failure codes in some consistent way when one or more actions in a batch failed.

I think the use case here is "automatically proceed with this thing I want to do if everything is okay; otherwise, stop, and tell me what broke so that I can intervene." In that use case, I think that we're okay proceeding if everything worked, and exiting with a non zero int if it didn't.

Changed in juju:
milestone: 2.9-beta1 → 2.9-rc1
Revision history for this message
Pen Gale (pengale) wrote :

This is covered by roadmap work this cycle. Adding to 3.0.0 milestone.

Changed in juju:
milestone: 2.9-rc1 → 3.0.0
Pen Gale (pengale)
Changed in juju:
importance: Medium → High
Revision history for this message
Joe Guo (guoqiao) wrote :

In my ceph osd conversion task for one of our customer, I used juju run-action in my script.
I have `set -xue` at the top of script, and was expecting that if any cmd failed, exit and don't run next ones, which is important for ceph/osd/bacahe/disk operations.
However, that didn't work as expected, and I figured out that juju run-action still return 0 even the action failed, which was a surprise to me.

So I strongly agree with the issue mentioned in this case, juju run-action should care about the actual retcode of underneath task and let the caller know.

Changed in juju:
milestone: 3.0.0 → 3.0.1
Changed in juju:
milestone: 3.0.1 → 3.0.2
Changed in juju:
milestone: 3.0.2 → 3.0.3
Revision history for this message
Juan M. Tirado (tiradojm) wrote :

I will move this to the wishlist.

Changed in juju:
importance: High → Wishlist
milestone: 3.0.3 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.