You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the following workflow (the corresponding workflow file is attached to this discussion, refer below to the "reproducing steps" section) where the comments document the encountered problem
# Workflow saved as/in sprig-usage-issue.yml file apiVersion: argoproj.io/v1alpha1kind: Workflowmetadata:
generateName: parameters-spec:
entrypoint: mainvolumes:
- name: workdirhostPath:
path: /data/hostarguments:
parameters:
- name: persistedVolume value: /data/host
- name: json# Seems to be a valid JSON according to some online validators e.g.# https://jsonlint.com/ or https://jsononline.net/json-validatorvalue: '["one","one\ntwo","one\ntwo\nthree"]'templates:
- name: mainsteps:
- - name: print-sprig-of-simple-liststemplate: whalesayarguments:
parameters:
- name: message# The whale will duly say# _______ # < three ># ------- value: "{{=sprig.last( ['one', 'two', 'three'] ) }}"
- - name: loop-write-some-resulttemplate: write-some-resultarguments:
parameters:
- name: some-file-contentvalue: "{{item}}"withItems:
- "one"
- "two"
- "three"
- - name: print-loop-resulttemplate: whalesayarguments:
parameters:
- name: message# This whale will behave and as expected say# _________________________________________ # / ["two\none","two\none","two\none\nthree \# \ "] /# ----------------------------------------- value: "{{steps.loop-write-some-result.outputs.parameters.results-values}}"
- - name: print-sprig-of-loop-result# If you try to print the following value with whalesay, you might get# the follwing error message# This shouldn't happen at /usr/share/perl/5.18/Text/Wrap.pm line 84.# We thus resolve to printing through other means template: print-pythonarguments:
parameters:
- name: message# But now the (python) printed message goes# {{=sprig.last(steps.loop-write-some-result.outputs.parameters.results-values) }}# that is the exact input string without the substitution that# expr is supposed (?) to realize, prior to interpreting the result.# Note that if this expr substitution is also inhibited when using# whalesay, this might explain why whalesay crashes (on that # obscure perl related error): the whalesay print gets confused by# its argument that is a mis-formed perl string...value: "{{=sprig.last(steps.loop-write-some-result.outputs.parameters.results-values) }}"
- name: write-some-resultinputs:
parameters:
- name: some-file-contentscript:
image: python:alpine3.6command: [python]source: | import os output_filename=os.path.join("{{workflow.parameters.persistedVolume}}", "results.txt") with open(output_filename, "a+") as f: f.write("{{inputs.parameters.some-file-content}}" + "\n")volumeMounts:
- name: workdirmountPath: /data/hostoutputs:
parameters:
- name: results-valuesvalueFrom:
path: "{{workflow.parameters.persistedVolume}}/results.txt"
- name: whalesayinputs:
parameters:
- name: messagecontainer:
image: docker/whalesay:latestcommand: [cowsay]args: ["{{inputs.parameters.message}}"]# When whalesay fails/crashes we need a plan B print
- name: print-pythoninputs:
parameters:
- name: messagescript:
image: python:alpine3.6command: [python]source: | print("{{inputs.parameters.message}}")
In addition one also gets the result.txt file, that should be located in the directory that was exposed to k8s as a persistent volume (that is your current working directory if you used e.g. minikube mount pwd:/data/host & : refer below to the "Reproducing steps" section").
The question is then: what needs to be changed (and in which way :-) in order to get sprig to be
properly executed on the aggregated result of the loop.
Reproducing steps
Download sprig-usage-issue.txt workflow
and change back its extension to yml (extension had to be changed for github to accept the document attachment) with
e.g. mv sprig-usage-issue.txt sprig-usage-issue.yml
argo lint sprig-usage-issue.yml should now report : ✔ no linting errors found!.
Trigger your k8s cluster e.g. with minikube start
Create an exported volume e.g. with minikube mount pwd:/data/host & (note that if you choose a different name for the volume then the arguments.parameters.persistedVolume entry of the sprig-usage-issue.yml workflow will need to be adapted accordingly).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Technical context
The difficulty
Consider the following workflow (the corresponding workflow file is attached to this discussion, refer below to the "reproducing steps" section) where the comments document the encountered problem
When triggering that workflow with e.g.
one gets
and the following output
In addition one also gets the
result.txt
file, that should be located in the directory that was exposed to k8s as a persistent volume (that is your current working directory if you used e.g.minikube mount
pwd:/data/host &
: refer below to the "Reproducing steps" section").The question is then: what needs to be changed (and in which way :-) in order to get sprig to be
properly executed on the aggregated result of the loop.
Reproducing steps
sprig-usage-issue.txt workflow
and change back its extension to
yml
(extension had to be changed for github to accept the document attachment) withe.g.
mv sprig-usage-issue.txt sprig-usage-issue.yml
argo lint sprig-usage-issue.yml
should now report :✔ no linting errors found!
.minikube start
minikube mount
pwd:/data/host &
(note that if you choose a different name for the volume then thearguments.parameters.persistedVolume
entry of thesprig-usage-issue.yml
workflow will need to be adapted accordingly).Beta Was this translation helpful? Give feedback.
All reactions