-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathretry-conditional.yaml
44 lines (42 loc) · 1.35 KB
/
retry-conditional.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Only retry if the retryStrategy.expression condition is satisfied. In this example, retries will be made until a pod has
# exit code 2 or the limit of 10 is reached, whichever happens first.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: retry-script-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: safe-to-retry
template: safe-to-retry
- - name: retry
template: retry-script
arguments:
parameters:
- name: safe-to-retry
value: "{{steps.safe-to-retry.outputs.result}}"
- name: safe-to-retry
script:
image: python:alpine3.6
command: ["python"]
source: |
print("true")
- name: retry-script
inputs:
parameters:
- name: safe-to-retry
retryStrategy:
limit: "10"
# Only continue retrying if the last exit code is greater than 1 and the input parameter is true
expression: "asInt(lastRetry.exitCode) > 1 && {{inputs.parameters.safe-to-retry}} == true"
script:
image: python:alpine3.6
command: ["python"]
# Exit 1 with 50% probability and 2 with 50%
source: |
import random;
import sys;
exit_code = random.choice([1, 2]);
sys.exit(exit_code)