event.fail message hidden

Bug #2052765 reported by Samuel Allan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
Medium
Unassigned

Bug Description

The event failure message for a failed action used to be printed, but now it isn't. It's only accessible if running the action with something other than the plain format (eg. `--format yaml`), or viewing the full output later through show-task.

Unsure if intended behaviour or not, but it is misleading (no feedback to the user by default when an action fails, leading them to believe it succeeded), and not consistent with the success state event output (which is printed by default when an action succeeds).

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

Are you talking about the action calling the "action-fail" command and the message passed to that command not being surfaced?

Revision history for this message
Samuel Allan (samuelallan) wrote (last edit ):

I think so - the message is recorded with juju as it should,
but it's not printed by default.

For example, if the code for an action handler (ops framework) looks like this (ignore the action name; it's copied from a project we're working on):

```
    def _on_get_lists_action(self, event: ops.charm.ActionEvent) -> None:
        """List tempest test lists action."""
        event.fail("this is the event fail message")
        return
```

Then this is an example set of interactions with it:

```
$ juju run tempest/0 get-lists
Running operation 33 with 1 task
  - task 34 on unit-tempest-0

Waiting for task 34...

$ echo $?
0

$ juju show-operation 33
summary: get-lists run on unit-tempest-0
status: failed
action:
  name: get-lists
  parameters: {}
timing:
  enqueued: 2024-02-22 23:57:23 +0000 UTC
  started: 2024-02-22 23:57:23 +0000 UTC
  completed: 2024-02-22 23:57:25 +0000 UTC
tasks:
  "34":
    host: tempest/0
    status: failed
    timing:
      enqueued: 2024-02-22 23:57:23 +0000 UTC
      started: 2024-02-22 23:57:23 +0000 UTC
      completed: 2024-02-22 23:57:25 +0000 UTC
    message: this is the event fail message
    results:
      return-code: 0

$ juju show-task 34

$ juju show-task 34 --format yaml
id: "34"
message: this is the event fail message
results:
  return-code: 0
status: failed
timing:
  completed: 2024-02-22 23:57:25 +0000 UTC
  enqueued: 2024-02-22 23:57:23 +0000 UTC
  started: 2024-02-22 23:57:23 +0000 UTC
unit: tempest/0

$ juju run tempest/0 get-lists --format yaml
Running operation 35 with 1 task
  - task 36 on unit-tempest-0

Waiting for task 36...
tempest/0:
  id: "36"
  message: this is the event fail message
  results:
    return-code: 0
  status: failed
  timing:
    completed: 2024-02-22 23:57:48 +0000 UTC
    enqueued: 2024-02-22 23:57:47 +0000 UTC
    started: 2024-02-22 23:57:47 +0000 UTC
  unit: tempest/0
```

The fail message is recorded, but the real issue is that it's not printed with the default plain formatter from juju.
It's only when showing the operation or task with yaml formatter, or running the action with the yaml formatter, is the failure made apparent.

This is an issue because it completely silences the failure for the default case of running the action,
leading the user to believe that the action succeeded:
no error message is displayed, and additionally the exit code is 0.

Note that in earlier versions of juju (2.9 from memory), this event failure message is indeed printed as expected.

Revision history for this message
Jack Shaw (jack-shaw) wrote :

What version on Juju did you see this?

Revision history for this message
Samuel Allan (samuelallan) wrote :

juju 3.2/stable I believe :)

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

This will affect all versions of juju from 2.9 onwards, but only 3.3 and later will get any fix.

Changed in juju:
milestone: none → 3.3.4
status: New → Triaged
tags: added: actions ui
Changed in juju:
milestone: 3.3.4 → none
importance: Undecided → Medium
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.