-
📝 https://argo-workflows.readthedocs.io/en/latest/variables/#exit-handler Perform the following steps in the ExitHandler, and if one of the steps fails, the Workflow itself marks it as failed, but a successful step returns success. metadata:
name: lovely-poochenheimer
namespace: default
labels:
example: 'true'
spec:
onExit: exit-handler
entrypoint: argosay
templates:
- name: argosay
container:
name: main
image: argoproj/argosay:v2
command:
- /argosay
args:
- echo
- 'hello argo'
- name: exit-handler
steps:
- - name: success
template: success
- name: failure
template: failure
- name: success
steps:
- - name: python-on-success
inline:
container:
name: main
image: public.ecr.aws/docker/library/python:alpine3.16
command: ["python", -c]
args: ["import random; import sys; exit_code = random.choice([0]); sys.exit(exit_code)"]
- name: cowsay
inline:
container:
name: main
image: docker/whalesay
command:
- cowsay
args:
- "{{workflow.status}}"
- name: failure
steps:
- - name: python-on-failure
inline:
container:
name: main
image: public.ecr.aws/docker/library/python:alpine3.16
command: ["python", -c]
args: ["import random; import sys; exit_code = random.choice([1]); sys.exit(exit_code)"] |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
As this is an exit handler, it uses the
The Workflow's final This is indeed a bit confusing, I believe there is an issue or something about this somewhere (need to check). There should perhaps be different behavior for exit handlers (and hooks), but it's a bit confusing either way. This example actually demonstrates that confusion; if the exit handler fails, should the workflow be considered succeeded because it succeeded prior to the exit handler? EDIT: Ah here's a more recent proposal that would apply here, separating continuation from final status determination: #12530. The explicitness there would resolve any confusion |
Beta Was this translation helpful? Give feedback.
As this is an exit handler, it uses the
status
just before to determine success or failure. Your first step was successful, and so it getsSucceeded
.The Workflow's final
status
is purely based on thestatus
of the final node, which, in this example, included a step that exited non-zero and so was reported as aFailure
.This is indeed a bit confusing, I believe there is an issue or something about this somewhere (need to check). There sho…