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

chore: Added examples for exit handler for step and dag level #3495

Merged
merged 6 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 58 additions & 0 deletions docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ Workflow is the definition of a workflow resource

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`exit-handlers.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handlers.yaml)

- [`forever.yaml`](https://github.com/argoproj/argo/blob/master/examples/forever.yaml)
Expand Down Expand Up @@ -391,6 +395,10 @@ WorkflowSpec is the specification of a Workflow.

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`exit-handlers.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handlers.yaml)

- [`forever.yaml`](https://github.com/argoproj/argo/blob/master/examples/forever.yaml)
Expand Down Expand Up @@ -713,6 +721,10 @@ CronWorkflowSpec is the specification of a CronWorkflow

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`exit-handlers.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handlers.yaml)

- [`forever.yaml`](https://github.com/argoproj/argo/blob/master/examples/forever.yaml)
Expand Down Expand Up @@ -998,6 +1010,10 @@ WorkflowTemplateSpec is a spec of WorkflowTemplate.

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`exit-handlers.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handlers.yaml)

- [`forever.yaml`](https://github.com/argoproj/argo/blob/master/examples/forever.yaml)
Expand Down Expand Up @@ -1267,6 +1283,10 @@ Arguments to a template

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`global-outputs.yaml`](https://github.com/argoproj/argo/blob/master/examples/global-outputs.yaml)

- [`global-parameters.yaml`](https://github.com/argoproj/argo/blob/master/examples/global-parameters.yaml)
Expand Down Expand Up @@ -1512,6 +1532,10 @@ Template is a reusable and composable unit of execution in a workflow

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`exit-handlers.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handlers.yaml)

- [`forever.yaml`](https://github.com/argoproj/argo/blob/master/examples/forever.yaml)
Expand Down Expand Up @@ -2009,6 +2033,10 @@ Parameter indicate a passed string parameter to a service template with an optio

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`global-outputs.yaml`](https://github.com/argoproj/argo/blob/master/examples/global-outputs.yaml)

- [`global-parameters.yaml`](https://github.com/argoproj/argo/blob/master/examples/global-parameters.yaml)
Expand Down Expand Up @@ -2195,6 +2223,8 @@ DAGTemplate is a template subtype for directed acyclic graph templates

- [`dag-targets.yaml`](https://github.com/argoproj/argo/blob/master/examples/dag-targets.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`loops-dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops-dag.yaml)

- [`parallelism-nested-dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/parallelism-nested-dag.yaml)
Expand Down Expand Up @@ -2303,6 +2333,10 @@ Inputs are the mechanism for passing parameters, artifacts, volumes from one tem

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`global-outputs.yaml`](https://github.com/argoproj/argo/blob/master/examples/global-outputs.yaml)

- [`handle-large-output-results.yaml`](https://github.com/argoproj/argo/blob/master/examples/handle-large-output-results.yaml)
Expand Down Expand Up @@ -2470,6 +2504,10 @@ Pod metdata

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`exit-handlers.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handlers.yaml)

- [`forever.yaml`](https://github.com/argoproj/argo/blob/master/examples/forever.yaml)
Expand Down Expand Up @@ -2837,6 +2875,8 @@ WorkflowStep is a reference to a template to execute in a series of step

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`exit-handlers.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handlers.yaml)

- [`fun-with-gifs.yaml`](https://github.com/argoproj/argo/blob/master/examples/fun-with-gifs.yaml)
Expand Down Expand Up @@ -3365,6 +3405,8 @@ DAGTask represents a node in the graph during DAG execution

- [`dag-targets.yaml`](https://github.com/argoproj/argo/blob/master/examples/dag-targets.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`loops-dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/loops-dag.yaml)

- [`parallelism-nested-dag.yaml`](https://github.com/argoproj/argo/blob/master/examples/parallelism-nested-dag.yaml)
Expand Down Expand Up @@ -3636,6 +3678,10 @@ ObjectMeta is metadata that all persisted resources must have, which includes al

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`exit-handlers.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handlers.yaml)

- [`forever.yaml`](https://github.com/argoproj/argo/blob/master/examples/forever.yaml)
Expand Down Expand Up @@ -4119,6 +4165,10 @@ A single application container that you want to run within a pod.

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`exit-handlers.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handlers.yaml)

- [`forever.yaml`](https://github.com/argoproj/argo/blob/master/examples/forever.yaml)
Expand Down Expand Up @@ -4756,6 +4806,10 @@ PersistentVolumeClaimSpec describes the common attributes of storage devices and

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`exit-handlers.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handlers.yaml)

- [`forever.yaml`](https://github.com/argoproj/argo/blob/master/examples/forever.yaml)
Expand Down Expand Up @@ -5736,6 +5790,10 @@ ListMeta describes metadata that synthetic resources must have, including lists

- [`exit-code-output-variable.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-code-output-variable.yaml)

- [`exit-handler-dag-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-dag-level.yaml)

- [`exit-handler-step-level.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handler-step-level.yaml)

- [`exit-handlers.yaml`](https://github.com/argoproj/argo/blob/master/examples/exit-handlers.yaml)

- [`forever.yaml`](https://github.com/argoproj/argo/blob/master/examples/forever.yaml)
Expand Down
50 changes: 50 additions & 0 deletions examples/exit-handler-dag-level.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This example demonstrates a DAG level exit handler that executes at the end of the task
## irrespective of the success, failure, or error of the task.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: exit-hanlder-dag-level-
spec:
entrypoint: main
templates:
- name: main
dag:
tasks:
- name: A
onExit: exit
template: echo
arguments:
parameters: [{name: message, value: A}]
- name: B
dependencies: [A]
onExit: exit
template: echo
arguments:
parameters: [{name: message, value: B}]
- name: C
dependencies: [A]
onExit: exit
template: echo
arguments:
parameters: [{name: message, value: C}]
- name: D
dependencies: [B, C]
onExit: exit
template: echo
arguments:
parameters: [{name: message, value: D}]

- name: echo
inputs:
parameters:
- name: message
container:
image: docker/whalesay
command: [cowsay]
args: ["{{inputs.parameters.message}}"]

- name: exit
container:
image: docker/whalesay
command: [cowsay]
args: ["task cleanup"]
41 changes: 41 additions & 0 deletions examples/exit-handler-step-level.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This example demonstrates a steps level exit handler that executes at the end of the step
## irrespective of the success, failure, or error of the step.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: exit-handler-step-level-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: hello1
onExit: exit
template: whalesay
arguments:
parameters: [{name: message, value: "hello1"}]
- - name: hello2a
onExit: exit
template: whalesay
arguments:
parameters: [{name: message, value: "hello2a"}]
- name: hello2b
onExit: exit
template: whalesay
arguments:
parameters: [{name: message, value: "hello2b"}]

- name: exit
container:
image: docker/whalesay
command: [cowsay]
args: ["step cleanup"]

- name: whalesay
inputs:
parameters:
- name: message
container:
image: docker/whalesay
command: [cowsay]
args: ["{{inputs.parameters.message}}"]