argoproj / argo-workflows

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

v3.4.6+ Cannot access output global artifacts in exit handler after upgrade #11610

Open ghulevishal opened 1 year ago

ghulevishal commented 1 year ago

Pre-requisites

What happened/what you expected to happen?

Whenever we are calling the global output artifact in the exithandler Its failing with the error:

Bad Request: templates.exit-handler.steps failed to resolve {{workflow.outputs.artifacts.output-result-car}}

This error was introduced after upgrading to the v3.4.6,. Also have tested with v3.4.7, v3.4.8, v3.4.9, v3.4.10 same issue persist.

After downgrading to v3.4.5 same workflow is working without any issue

Version

v3.4.6

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

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: exit-handler-with-artifacts
spec:
  onExit: exit-handler
  entrypoint: main
  arguments:
    parameters:
    - name: params
      value: |
        [
          { "variable": "car"},
          { "variable": "bike"}
        ]
  templates:
    - name: main
      steps:
        - - name: step-1
            template: output
            arguments:
              parameters:
                - name: variable
                  value: "{{item.variable}}"
            withParam: "{{workflow.parameters.params}}" 

    - name: output
       inputs:
        parameters:
        - name: variable
      script:
        image: python:alpine3.6
        command: [sh, -c]
        args: ["echo $variable > /result.txt "]
      outputs:
        artifacts:
          - name: result-{{inputs.parameters.variable}}
            path: /result.txt
            globalName: output-result-{{inputs.parameters.variable}}

    - name: printer
      inputs:
        artifacts:
          - name: message-bike
            path: /tmp/message-bike
          - name: message-car
            path: /tmp/message-car
      container:
        image: python:alpine3.6
        command: [sh, -c]
        args: ["cat /tmp/message.*"]

    - name: exit-handler
      steps:
        - - name: printer
            template: printer
            arguments:
              artifacts:
              - name: message-car
                from: "{{workflow.outputs.artifacts.output-result-car}}"          
              - name: message-bike
                from: "{{workflow.outputs.artifacts.output-result-bike}}" 

Logs from the workflow controller

NA

Logs from in your workflow's wait container

NA
sarabala1979 commented 1 year ago

Based on initial triage. GlobalArtifacts are not included in the scope to replace/substitute for the exit handler. Scope should populate the globalartifacts https://github.com/argoproj/argo-workflows/blob/f5e31f8f36b32883087f783cb1227490bbe36bbd/workflow/controller/operator.go#L3081

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Luobiny commented 5 months ago

Any update on this?

Luobiny commented 4 months ago

An issue related to this one: the global output variables cannot be accessed in in exit handler either. Argo complains that {{workflow.outputs.parameters.global_variable_name}} cannot be resolved.

omerlh commented 1 month ago

Facing same issue as @Luobiny , are there any estimations to when this will be solved?

tooptoop4 commented 2 weeks ago

canz https://github.com/argoproj/argo-workflows/pull/11738 🐝 📂