argoproj / argo-workflows

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

Hooks in steps use artifacts unable to submit #13860

Open shuangkun opened 3 weeks ago

shuangkun commented 3 weeks ago

Pre-requisites

What happened? What did you expect to happen?

When I submit the workflow, the following error is displayed

#shuangkun% argo submit test.yaml
FATA[2024-11-03T18:22:46.100Z] Failed to submit workflow: rpc error: code = InvalidArgument desc = templates.main.steps failed to resolve {{steps.hello1.outputs.artifacts.result}}

I hope to be able to submit the workflow normally.

Version(s)

latest

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.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: test-hook-
spec:
  entrypoint: main
  templates:
  - name: main
    steps:
    - - name: hello1            # hello1 is run before the following steps
        template: parameterization
        hooks:
          success:
            template: success-hook
            expression: steps["hello1"].status == "Succeeded"
            arguments:
              artifacts:
              - name: file_path
                from: "{{steps.hello1.outputs.artifacts.result}}"

  - name: parameterization
    script:
      image: python:3.8
      command: [python]
      source: |
        import os
        with open("foo.txt", "w") as f:
            f.write("Hello")
        # 模拟输出文件作为artifact
        os.rename('foo.txt', '/tmp/foo.txt')
    outputs:
      artifacts:
      - name: result
        path: /tmp/foo.txt

  - name: success-hook
    inputs:
      artifacts:
      - name: file_path
        path: /tmp/file_path
    script:
      image: python:3.8
      command: [sh, -c]
      source: |
        echo "File Path: {{inputs.artifacts.file_path.path}}"

### Logs from the workflow controller

```text
kubectl logs -n argo deploy/workflow-controller | grep ${workflow}

Logs from in your workflow's wait container

kubectl logs -n argo -c wait -l workflows.argoproj.io/workflow=${workflow},workflow.argoproj.io/phase!=Succeeded