6

根据Argo DAG 模板文档

tasks.<TASKNAME>.outputs.parameters:当上一个任务使用 'withItems' 或 'withParams' 时,这包含每个调用的输出参数映射的 JSON 数组

尝试使用以下简单工作流程时:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: test-workflow-
spec:
  entrypoint: start
  templates:
  - name: start
    dag:
      tasks:
        - name: with-items
          template: hello-letter
          arguments:
            parameters:
            - name: input-letter
              value: "{{item}}"
          withItems:
          - A
          - B
          - C
        - name: show-result
          dependencies:
          - with-items
          template: echo-result
          arguments:
            parameters:
            - name: input
              value: "{{tasks.with-items.outputs.parameters}}"

  - name: hello-letter
    inputs:
      parameters:
      - name: input-letter
    outputs:
      parameters:
      - name: output-letter
        value: "{{inputs.parameters.input-letter}}"
    script:
      image: alpine
      command: ["sh"]
      source: |
        echo "{{inputs.parameters.input-letter}}"

  - name: echo-result
    inputs:
      parameters:
      - name: input
    outputs:
      parameters:
      - name: output
        value: "{{inputs.parameters.input}}"
    script:
      image: alpine
      command: ["sh"]
      source: |
        echo {{inputs.parameters.input}}

我收到以下错误: Failed to submit workflow: templates.start.tasks.show-result failed to resolve {{tasks.with-items.outputs.parameters}}

Argo 版本(在 minikube 集群中运行)

argo: v2.10.0+195c6d8.dirty
  BuildDate: 2020-08-18T23:06:32Z
  GitCommit: 195c6d8310a70b07043b9df5c988d5a62dafe00d
  GitTreeState: dirty
  GitTag: v2.10.0
  GoVersion: go1.13.4
  Compiler: gc
  Platform: darwin/amd64

Argo 2.8.1 中出现同样的错误,尽管在 show-result 任务中使用.result而不是.parameters正常工作(结果是[A,B,C]),但在 2.10 中不再工作

        - name: show-result
          dependencies:
          - with-items
          template: echo-result
          arguments:
            parameters:
            - name: input
              value: "{{tasks.with-items.outputs.result}}"

结果:

STEP                                TEMPLATE      PODNAME                                     DURATION  MESSAGE
 ⚠ test-workflow-parallelism-xngg4  start                                                                                                                     
 ├-✔ with-items(0:A)                hello-letter  test-workflow-parallelism-xngg4-3307649634  6s                                                              
 ├-✔ with-items(1:B)                hello-letter  test-workflow-parallelism-xngg4-768315880   7s                                                              
 ├-✔ with-items(2:C)                hello-letter  test-workflow-parallelism-xngg4-2631126026  9s                                                              
 └-⚠ show-result                    echo-result                                                         invalid character 'A' looking for beginning of value

我还尝试将 show-result 任务更改为:

        - name: show-result
          dependencies:
          - with-items
          template: echo-result
          arguments:
            parameters:
            - name: input
              value: "{{tasks.with-items.outputs.parameters.output-letter}}"

执行没有错误:

STEP                                TEMPLATE      PODNAME                                     DURATION  MESSAGE
 ✔ test-workflow-parallelism-qvp72  start                                                                 
 ├-✔ with-items(0:A)                hello-letter  test-workflow-parallelism-qvp72-4221274474  8s          
 ├-✔ with-items(1:B)                hello-letter  test-workflow-parallelism-qvp72-112866000   9s          
 ├-✔ with-items(2:C)                hello-letter  test-workflow-parallelism-qvp72-1975676146  6s          
 └-✔ show-result                    echo-result   test-workflow-parallelism-qvp72-3460867848  3s 

但是参数不会被值替换:

argo logs test-workflow-parallelism-qvp72
test-workflow-parallelism-qvp72-1975676146: 2020-08-25T14:52:50.622496755Z C
test-workflow-parallelism-qvp72-4221274474: 2020-08-25T14:52:52.228602517Z A
test-workflow-parallelism-qvp72-112866000: 2020-08-25T14:52:53.664320195Z B
test-workflow-parallelism-qvp72-3460867848: 2020-08-25T14:52:59.628892135Z {{tasks.with-items.outputs.parameters.output-letter}}

我不明白循环的输出会发生什么!我错过了什么?有没有办法找出正在发生的事情?

4

2 回答 2

0

这是我遇到的一个很常见的问题,到目前为止,我还没有在任何错误报告或功能文档中遇到过这个问题,因此尚未确定这是一个功能还是错误。然而,argo 显然无法执行“map-reduce”流 OOB。

我发现的唯一“真正”解决方法是附加一个工件,将with-items任务输出写入它,然后将其传递到下一步,您将在代码/脚本中通过读取来自人工制品。

- - 编辑 - - -

正如另一个答案所提到的,这确实是一个已针对最新版本解决的错误,这解决了parameters您提到的作为选项的使用,但outputs.result仍然导致错误修复后的错误。

于 2022-01-20T16:37:14.563 回答
0

在 Argo 版本 3.2.5 之前存在导致此错误的错误。升级到最新版本,然后重试。

看起来问题仅出在 CLI 中。我用 提交了工作流kubectl apply,它运行良好。该错误仅出现在argo submit.

argo submit当我升级到 3.2.6 时,该错误已解决。

于 2022-01-20T17:10:04.287 回答