argo workflow retryStrategy override

Viewed 693

is there any way to override values of "WorkflowTemplate-retryStrategy" in argo ?

Currently we are using hardcoded retryStrategy in Argo WorkflowTemplate like below (sample code):

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: workflowtemplate-1
spec:
  entrypoint: task-template-1
  arguments:
    parameters:
    - name: "test"
      value: "testing"
  templates:
  - name: task-template-1
    retryStrategy:
      limit: 1
      retryPolicy: "Always"
    inputs:
        parameters:
          - name: "test"

Is there any way where we can override it as part of workflow arguments (or anything similar)? like commented "#" values in below code:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: sample-workflow
spec:
  workflowTemplateRef:
    name: workflowtemplate-1
  # retryStrategy:
  #   limit: 3
  #   retryPolicy: "Always"
  arguments:
    parameters:
  #  - name: "retry"
  #    value: "2"
1 Answers

Yep! Just set up a workflow parameter for the retry limit.

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: workflowtemplate-1
spec:
  entrypoint: task-template-1
  arguments:
    parameters:
      - name: "retry"
        value: "1"
  templates:
    - name: task-template-1
      retryStrategy:
        limit: "{{workflow.parameters.retry}}"
        retryPolicy: "Always"
      container:
        image: docker/whalesay:latest
        command: ["false"]

---

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: sample-workflow
spec:
  workflowTemplateRef:
    name: workflowtemplate-1
  arguments:
    parameters:
    - name: "retry"
      value: "2"

If you submit sample-workflow, you'll see that it retries twice instead of just the default once.

Note: templating the limit field was introduced in 2.11.0-rc1.

If you're stuck with an earlier version, there is a workaround.

Related