# Only retry if the retryStrategy.expression condition is satisfied. In this # example, retries will be made until a pod matches the condition or the limit # of 10 is reached, whichever happens first. apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: retry-script- labels: workflows.argoproj.io/no-test: "environment" 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.23 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, the # phase of the last status wasn't "Error", the duration was less than 2 # minutes, and either the input parameter is true or the message matches # the regex 'imminent node shutdown|pod deleted' expression: >- asInt(lastRetry.exitCode) > 1 && lastRetry.status != "Error" && asInt(lastRetry.duration) < 120 && ({{inputs.parameters.safe-to-retry}} == true || lastRetry.message matches 'imminent node shutdown|pod deleted') script: image: python:alpine3.23 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)