Skip to content

Commit

Permalink
chore: Added examples for exit handler for step and dag level (#3495)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarabala1979 committed Jul 16, 2020
1 parent bcb3254 commit e244337
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 0 deletions.
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}}"]

0 comments on commit e244337

Please sign in to comment.