argo-workflows: Error with expr from parameter output another step

Checklist

  • Double-checked my configuration.
  • Tested using the latest version.
  • Used the Emissary executor.

Summary

What happened/what you expected to happen?

When on a when field add an expr with output task I get the next error:

Failed: invalid spec: templates.main when doesn’t support ‘expr’ expression ‘{{=’. ‘When’ expression is only support govaluate format {{

the expr I’m using is:

when: “{{=jsonpath(tasks.checkout.outputs.parameters.custom_config, ‘$.steps.test_unit.skip’)}}”

However when I use and input parameter with expr everything works correctly, but I don’t have use an input parameter because, I need use the output parameter to another task and I get a json file.

when: “{{=inputs.parameters.BRANCH == ‘false’}}”

Which this expr works correctly

What version are you running?

Argo-workflows: 3.3.6 Kubernetes: 1.22.9

Diagnostics

Paste the smallest workflow that reproduces the bug. We must be able to run the workflow.

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: example
  entrypoint: main
  templates:
    - name: main
      inputs:
        parameters:
          - name: URL
          - name: BRANCH 
      dag:
        tasks:
        - name: checkout
          templateRef:
            name: checkout
            template: main
          arguments:
            parameters:
              - name: git_ssh_url
                value: "git@{{= sprig.replace('net/', 'net:', sprig.substr( 8, -1, inputs.parameters.URL)) }}"
              - name: BRANCH
                value: "{{inputs.parameters.BRANCH}}"
...
...
        - name: test-unit
          templateRef:
            name: unit-test
            template: node-web
          arguments:
            parameters:
              - name: PROJECT_NAME
                value: "{{workflow.parameters.PROJECT_NAME}}"
# Get value for testing
              - name: SKIP
                value: "{{=jsonpath(tasks.checkout.outputs.parameters.custom_config, '$.steps.test_unit.skip')}}"
          when: "{{=jsonpath(tasks.checkout.outputs.parameters.custom_config, '$.steps.test_unit.skip') == 'false'}}"

...
kubectl logs -n argo-workflows deploy/workflow-controller | grep example-db6tm

# If the workflow's pods have not been created, you can skip the rest of the diagnostics.

# The workflow's pods that are problematic:
kubectl get pod -o yaml -l workflows.argoproj.io/workflow=example-db6tm,workflow.argoproj.io/phase!=Succeeded

# Logs from in your workflow's wait container, something like:
kubectl logs -c wait -l workflows.argoproj.io/workflow=example-db6tm,workflow.argoproj.io/phase!=Succeeded
time="2022-06-03T20:18:11.654Z" level=info msg="Processing workflow" namespace=argo-events workflow=example-db6tm
time="2022-06-03T20:18:11.789Z" level=info msg="Updated phase  -> Failed" namespace=argo-events workflow=example-db6tm
time="2022-06-03T20:18:11.789Z" level=info msg="Updated message  -> invalid spec: templates.main when doesn't support 'expr' expression '{{='. 'When' expression is only support govaluate format {{" namespace=argo-events workflow=example-db6tm
time="2022-06-03T20:18:11.789Z" level=info msg="Marking workflow completed" namespace=argo-events workflow=example-db6tm
time="2022-06-03T20:18:11.789Z" level=info msg="Marking workflow as pending archiving" namespace=argo-events workflow=example-db6tm
time="2022-06-03T20:18:11.790Z" level=error msg="Unable to set ExecWorkflow" error="templates.main when doesn't support 'expr' expression '{{='. 'When' expression is only support govaluate format {{" namespace=argo-events workflow=example-db6tm
time="2022-06-03T20:18:11.790Z" level=info msg="Checking daemoned children of " namespace=argo-events workflow=example-db6tm
time="2022-06-03T20:18:11.795Z" level=info msg="cleaning up pod" action=deletePod key=argo-events/example-db6tm-1340600742-agent/deletePod
time="2022-06-03T20:18:11.813Z" level=info msg="Workflow update successful" namespace=argo-events phase=Failed resourceVersion=49713004 workflow=example-db6tm
time="2022-06-03T20:18:11.824Z" level=info msg="archiving workflow" namespace=argo-events uid=b2e5b49b-db7d-427c-9859-dec6d546fc40 workflow=example-db6tm
time="2022-06-03T20:18:11.871Z" level=info msg="Queueing Failed workflow argo-events/example-db6tm for delete in 1m0s due to TTL"
apiVersion: v1
items: []
kind: List
metadata:
  resourceVersion: ""
No resources found in argo-events namespace.

Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 6
  • Comments: 22 (13 by maintainers)

Most upvoted comments

Any news on this issue?

@vermaxik In my case only use this feature to skip steps.

During firts step I create a config file, however with expr doesn’t work for my case. But how I only need get if boolean attribute is True or False, I create others files only with this attribute value.

Example: I create the file /tmp/step1_skip.txt, on this file on write True or False. and with outputs parameters get this value of file and next steps Use this output on when field to skip this step.

step0

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: step0
spec:
  entrypoint: main
  templates:
    - name: main
      inputs:
        parameters:
          - name: git_ssh_url
          - name: BRANCH
        artifacts:
          - name: git-clone
            path: "/workspace/project"
            git:
              revision: "{{inputs.parameters.BRANCH}}"
              repo: "{{inputs.parameters.git_ssh_url}}"
              singleBranch: false
              sshPrivateKeySecret:
                name: github
                key: id_rsa
              insecureIgnoreHostKey: true
            optional: true
      outputs:
        parameters:
        - name: custom
          valueFrom:
            path: "/workspace/custom.json"
        - name: step1_skip
          description: "Skip step1 step"
          valueFrom:
            path: "/tmp/step1_skip"
        - name: step2_skip
          description: "Skip step2 step"
          valueFrom:
            path: "/tmp/step2_skip"
      container:
        imagePullPolicy: Always
        image: xxxxxxx:1.0.0
        workingDir: "/workspace/project"
        resources:
          limits:
            cpu: 500m
            memory: 512Mi
          requests:
            cpu: 200m
            memory: 256Mi
        command:
          - "python"
        args:
          - "/my-script.py"
          - "param1"

main workflow

apiVersion: argoproj.io/v1alpha1
kind: ClusterWorkflowTemplate
metadata:
  name: pipeline
spec:
  entrypoint: main 
  templates:
    - name: main
      dag:
        tasks:
        - name: step0
          templateRef:
            name: step0
            template: main
          arguments:
            parameters:
              - name: git_ssh_url
                value: "XXXXXXXXXX"
              - name: BRANCH
                value: "XXXXXXXXX"
        - name: step1
          templateRef:
            name: step1
            template: main
          depends: "step0"
          when: "{{tasks.checkout.outputs.parameters.step0_skip}} =~ '^(false|False)$'"
....