argoproj / argo-workflows

Workflow Engine for Kubernetes
https://argo-workflows.readthedocs.io/
Apache License 2.0
15.11k stars 3.21k forks source link

Parameters values escaping problem #13718

Open DoNck opened 1 month ago

DoNck commented 1 month ago

Pre-requisites

What happened? What did you expect to happen?

Hi Argo.

I am running the latest stable release (3.5.11) of argo-workflows. It seems a character escaping issue occurs during template rendering.

When feeding withParams or withItems with special characters, some wrong escaping occurs and container is called with wrong parameters, which is visible in the "inputs/outputs" tab of the side panel. Depending on the input string, pods can be badly named in the graph view. screenshot_annotated

Parameters received by the debug pod: python_debug_logs (see the note below regarding the debug pod)

Moreover the displayed pod name does not share the same numerical identifier as the "ID". In this situation, the "Logs" button will not work. The logs are accessible from kubectl using the actual pod name (not being displayed). bad_id

Note: The provided custom image is intended for debugging this particular issue and can be built from this archive docker.zip using the following command: docker build -t localhost:5000/library/printarg:dev ..

As a workfaround, I managed to provide correct parameters to the python script using sprig to post-process the wrong escapes I encountered (double quote and backslashes). You can try calling the python script using param_workaround instead of param parameter.

Version(s)

v3.5.11

Paste a minimal workflow that reproduces the issue. We must be able to run the workflow; don't enter a workflows that uses private images.

metadata:
  name: escaping-problem
spec:
  templates:
    - name: do-something
      inputs:
        parameters:
          - name: param
          - name: param_workaround
      container:
        image: printargs:dev
        command:
          - python
        args:
          - /printarg.py
          - '-a'
          - '{{inputs.parameters.param}}'
        env:
          - name: PYTHONUNBUFFERED
            value: '1'
        imagePullPolicy: Always
    - name: entrypoint
      steps:
        - - name: do-something
            template: do-something
            arguments:
              parameters:
                - name: param
                  value: '{{item}}'
                - name: param_workaround
                  value: >-
                    {{=sprig.replace("\\\\", "\u005c", sprig.replace("\\\"",
                    "\u0022", item))}}
            withItems:
              - abcd
              - efgh
              - ij"kl
              - mn\"op
              - qr\\"st
              - UV&é"'$(-
  entrypoint: entrypoint

Logs from the workflow controller

time="2024-10-07T09:29:11.266Z" level=info msg="Processing workflow" Phase= ResourceVersion=4249744 namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.326Z" level=info msg="Task-result reconciliation" namespace=myns numObjs=0 workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.326Z" level=info msg="Updated phase  -> Running" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.328Z" level=warning msg="Node was nil, will be initialized as type Skipped" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.329Z" level=info msg="was unable to obtain node for , letting display name to be nodeName" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.329Z" level=info msg="Steps node escaping-problem-dhwxh initialized Running" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.329Z" level=info msg="StepGroup node escaping-problem-dhwxh-826472279 initialized Running" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.331Z" level=warning msg="Node was nil, will be initialized as type Skipped" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.331Z" level=info msg="Pod node escaping-problem-dhwxh-122118802 initialized Pending" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.345Z" level=info msg="Created pod: escaping-problem-dhwxh[0].do-something(0:abcd) (escaping-problem-dhwxh-do-something-122118802)" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.345Z" level=warning msg="Node was nil, will be initialized as type Skipped" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.345Z" level=info msg="Pod node escaping-problem-dhwxh-3303604141 initialized Pending" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.357Z" level=info msg="Created pod: escaping-problem-dhwxh[0].do-something(1:efgh) (escaping-problem-dhwxh-do-something-3303604141)" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.357Z" level=warning msg="Node was nil, will be initialized as type Skipped" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.357Z" level=info msg="Pod node escaping-problem-dhwxh-625910082 initialized Pending" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.365Z" level=info msg="Created pod: escaping-problem-dhwxh[0].do-something(2:ij\\\"kl) (escaping-problem-dhwxh-do-something-625910082)" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.365Z" level=warning msg="Node was nil, will be initialized as type Skipped" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.366Z" level=info msg="Pod node escaping-problem-dhwxh-195136337 initialized Pending" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.373Z" level=info msg="Created pod: escaping-problem-dhwxh[0].do-something(3:mn\\\\\\\"op) (escaping-problem-dhwxh-do-something-195136337)" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.373Z" level=warning msg="Node was nil, will be initialized as type Skipped" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.373Z" level=info msg="Pod node escaping-problem-dhwxh-999571824 initialized Pending" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.380Z" level=info msg="Created pod: escaping-problem-dhwxh[0].do-something(4:qr\\\\\\\\\\\"st) (escaping-problem-dhwxh-do-something-999571824)" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.380Z" level=warning msg="Node was nil, will be initialized as type Skipped" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.380Z" level=info msg="Pod node escaping-problem-dhwxh-1679321178 initialized Pending" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.390Z" level=info msg="Created pod: escaping-problem-dhwxh[0].do-something(5:UV&é\\\"'$-) (escaping-problem-dhwxh-do-something-1679321178)" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.390Z" level=info msg="Workflow step group node escaping-problem-dhwxh-826472279 not yet completed" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.390Z" level=info msg="TaskSet Reconciliation" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.390Z" level=info msg=reconcileAgentPod namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:11.403Z" level=info msg="Workflow update successful" namespace=myns phase=Running resourceVersion=4249767 workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.267Z" level=info msg="Processing workflow" Phase=Running ResourceVersion=4249767 namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.267Z" level=info msg="Task-result reconciliation" namespace=myns numObjs=6 workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.267Z" level=info msg="node changed" namespace=myns new.message= new.phase=Succeeded new.progress=0/1 nodeID=escaping-problem-dhwxh-195136337 old.message= old.phase=Pending old.progress=0/1 workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.268Z" level=info msg="node changed" namespace=myns new.message= new.phase=Succeeded new.progress=0/1 nodeID=escaping-problem-dhwxh-999571824 old.message= old.phase=Pending old.progress=0/1 workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.268Z" level=info msg="node changed" namespace=myns new.message= new.phase=Succeeded new.progress=0/1 nodeID=escaping-problem-dhwxh-1679321178 old.message= old.phase=Pending old.progress=0/1 workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.268Z" level=info msg="node changed" namespace=myns new.message= new.phase=Succeeded new.progress=0/1 nodeID=escaping-problem-dhwxh-3303604141 old.message= old.phase=Pending old.progress=0/1 workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.268Z" level=info msg="node changed" namespace=myns new.message= new.phase=Succeeded new.progress=0/1 nodeID=escaping-problem-dhwxh-625910082 old.message= old.phase=Pending old.progress=0/1 workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.268Z" level=info msg="node changed" namespace=myns new.message= new.phase=Succeeded new.progress=0/1 nodeID=escaping-problem-dhwxh-122118802 old.message= old.phase=Pending old.progress=0/1 workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="Step group node escaping-problem-dhwxh-826472279 successful" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="node escaping-problem-dhwxh-826472279 phase Running -> Succeeded" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="node escaping-problem-dhwxh-826472279 finished: 2024-10-07 09:29:21.270054563 +0000 UTC" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="Outbound nodes of escaping-problem-dhwxh-122118802 is [escaping-problem-dhwxh-122118802]" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="Outbound nodes of escaping-problem-dhwxh-3303604141 is [escaping-problem-dhwxh-3303604141]" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="Outbound nodes of escaping-problem-dhwxh-625910082 is [escaping-problem-dhwxh-625910082]" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="Outbound nodes of escaping-problem-dhwxh-195136337 is [escaping-problem-dhwxh-195136337]" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="Outbound nodes of escaping-problem-dhwxh-999571824 is [escaping-problem-dhwxh-999571824]" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="Outbound nodes of escaping-problem-dhwxh-1679321178 is [escaping-problem-dhwxh-1679321178]" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="Outbound nodes of escaping-problem-dhwxh is [escaping-problem-dhwxh-122118802 escaping-problem-dhwxh-3303604141 escaping-problem-dhwxh-625910082 escaping-problem-dhwxh-195136337 escaping-problem-dhwxh-999571824 escaping-problem-dhwxh-1679321178]" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="node escaping-problem-dhwxh phase Running -> Succeeded" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="node escaping-problem-dhwxh finished: 2024-10-07 09:29:21.270222657 +0000 UTC" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="TaskSet Reconciliation" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg=reconcileAgentPod namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="Updated phase Running -> Succeeded" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.270Z" level=info msg="Marking workflow completed" namespace=myns workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.286Z" level=info msg="Workflow update successful" namespace=myns phase=Succeeded resourceVersion=4249915 workflow=escaping-problem-dhwxh
time="2024-10-07T09:29:21.336Z" level=info msg="cleaning up pod" action=labelPodCompleted key=myns/escaping-problem-dhwxh-do-something-195136337/labelPodCompleted
time="2024-10-07T09:29:21.337Z" level=info msg="cleaning up pod" action=labelPodCompleted key=myns/escaping-problem-dhwxh-do-something-999571824/labelPodCompleted
time="2024-10-07T09:29:21.337Z" level=info msg="cleaning up pod" action=labelPodCompleted key=myns/escaping-problem-dhwxh-do-something-122118802/labelPodCompleted
time="2024-10-07T09:29:21.337Z" level=info msg="cleaning up pod" action=labelPodCompleted key=myns/escaping-problem-dhwxh-do-something-1679321178/labelPodCompleted
time="2024-10-07T09:29:21.349Z" level=info msg="cleaning up pod" action=labelPodCompleted key=myns/escaping-problem-dhwxh-do-something-3303604141/labelPodCompleted
time="2024-10-07T09:29:21.349Z" level=info msg="cleaning up pod" action=labelPodCompleted key=myns/escaping-problem-dhwxh-do-something-625910082/labelPodCompleted

Logs from in your workflow's wait container

time="2024-10-07T09:29:12.836Z" level=info msg="Executor initialized" deadline="0001-01-01 00:00:00 +0000 UTC" includeScriptOutput=false namespace=myns podName=escaping-problem-dhwxh-do-something-1679321178 templateName=do-something version="&Version{Version:v3.5.11,BuildDate:2024-09-20T14:09:00Z,GitCommit:25bbb71cced32b671f9ad35f0ffd1f0ddb8226ee,GitTag:v3.5.11,GitTreeState:clean,GoVersion:go1.21.13,Compiler:gc,Platform:linux/amd64,}"
time="2024-10-07T09:29:13.544Z" level=info msg="Executor initialized" deadline="0001-01-01 00:00:00 +0000 UTC" includeScriptOutput=false namespace=myns podName=escaping-problem-dhwxh-do-something-195136337 templateName=do-something version="&Version{Version:v3.5.11,BuildDate:2024-09-20T14:09:00Z,GitCommit:25bbb71cced32b671f9ad35f0ffd1f0ddb8226ee,GitTag:v3.5.11,GitTreeState:clean,GoVersion:go1.21.13,Compiler:gc,Platform:linux/amd64,}"
time="2024-10-07T09:29:13.310Z" level=info msg="Executor initialized" deadline="0001-01-01 00:00:00 +0000 UTC" includeScriptOutput=false namespace=myns podName=escaping-problem-dhwxh-do-something-3303604141 templateName=do-something version="&Version{Version:v3.5.11,BuildDate:2024-09-20T14:09:00Z,GitCommit:25bbb71cced32b671f9ad35f0ffd1f0ddb8226ee,GitTag:v3.5.11,GitTreeState:clean,GoVersion:go1.21.13,Compiler:gc,Platform:linux/amd64,}"
time="2024-10-07T09:29:12.839Z" level=info msg="Executor initialized" deadline="0001-01-01 00:00:00 +0000 UTC" includeScriptOutput=false namespace=myns podName=escaping-problem-dhwxh-do-something-625910082 templateName=do-something version="&Version{Version:v3.5.11,BuildDate:2024-09-20T14:09:00Z,GitCommit:25bbb71cced32b671f9ad35f0ffd1f0ddb8226ee,GitTag:v3.5.11,GitTreeState:clean,GoVersion:go1.21.13,Compiler:gc,Platform:linux/amd64,}"
time="2024-10-07T09:29:13.326Z" level=info msg="Executor initialized" deadline="0001-01-01 00:00:00 +0000 UTC" includeScriptOutput=false namespace=myns podName=escaping-problem-dhwxh-do-something-999571824 templateName=do-something version="&Version{Version:v3.5.11,BuildDate:2024-09-20T14:09:00Z,GitCommit:25bbb71cced32b671f9ad35f0ffd1f0ddb8226ee,GitTag:v3.5.11,GitTreeState:clean,GoVersion:go1.21.13,Compiler:gc,Platform:linux/amd64,}"
time="2024-10-07T09:29:13.521Z" level=info msg="Executor initialized" deadline="0001-01-01 00:00:00 +0000 UTC" includeScriptOutput=false namespace=myns podName=escaping-problem-dhwxh-do-something-122118802 templateName=do-something version="&Version{Version:v3.5.11,BuildDate:2024-09-20T14:09:00Z,GitCommit:25bbb71cced32b671f9ad35f0ffd1f0ddb8226ee,GitTag:v3.5.11,GitTreeState:clean,GoVersion:go1.21.13,Compiler:gc,Platform:linux/amd64,}"