Using Argo to execute workflows last week, I met some problems and also find the solutions.
1. Can’t parse “outputs”
By submitting this YAML file:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: robin-test-
spec:
entrypoint: firststep
templates:
- name: firststep
steps:
- - name: generate
template: generate-run
- - name: execution
template: execution-run
arguments:
parameters:
- name: pair
value: "{{item}}"
withParam: "{{steps.generate.outputs.result}}"
- name: generate-run
container:
image: gcr.io/robin/feature:latest
command: ["bash", "-c"]
args: ["cat my.json"]
- name: execution-run
inputs:
parameters:
- name: pair
container:
image: docker/whalesay
command: [cowsay]
args: ["{{inputs.parameters.pair}}"]
I met the error:
Failed to submit workflow: templates.firststep.steps[1].execution failed to resolve {{steps.generate.outputs.result}}]
Why the Argo could’t recognize the “steps.generate.outputs.result”? Because only “source” could have a default “output”, not “args”. So the template “generate-run” should be
...
- name: generate-run
container:
image: gcr.io/robin/feature:latest
command: ["bash", "-c"]
source: |
cat my.json
2. Can’t parse parameters from JSON
If the Argo report:
withParam value could not be parsed as a JSON list: xxx
it means the “output” of the previous step isn’t in standard JSON format. So make sure you have pretty JSON format output. For python, it should be like:
...
- name: generate-run
container:
image: gcr.io/robin/feature:latest
command: ["bash", "-c"]
source: |
python -c "import json; json.dump([{'id': key, 'name': value} for key, value in dictionary], sys.stdout)"