Argo 模板无法从输出文件位置读取

Argo template not able to read from output file location

一个 outer-template 调用 inner-template 两次,因为有 2 个步骤。内部模板是一个简单的容器,可以将一些文本写入 /command_output/result.txt。工作流输出尝试通过以下方式读取它:

- name: previous_step_output
  valueFrom:
    path: /command_output/result.txt

出于某种原因,这似乎确实有效。根据文档,我还创建了 volumesvolumeMounts 错误是:

 Service Account Name:  argo
  Templates:
    Arguments:
    Inputs:
    Metadata:
    Name:  HelloWorld
    Outputs:
    Steps:
      [map[arguments:map[parameters:[map[name:message value:Hello World.....]]] name:init-step templateRef:map[name:outer-template template:HelloWorld]]]
Status:
  Conditions:
    Status:     True
    Type:       Completed
  Finished At:  2021-06-17T23:50:37Z
  Message:      runtime error: invalid memory address or nil pointer dereference
  Nodes:
    hello-css4z:

需要一些关于缺少什么的建议。附加内部模板、外部模板和 request.yaml.

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: inner-template
  namespace: cali
  labels:
    workflows.argoproj.io/controller-instanceid: cali
spec:
  templates:
    - name: InnerJob
      metadata:
        annotations:
          sidecar.istio.io/inject: "false"
      inputs:
        parameters:
          - name: message
          - name: previous_step_output
            value: ""
      resource:
        action: create
        successCondition: status.succeeded > 0
        failureCondition: status.failed > 0
        manifest: |
          apiVersion: batch/v1
          kind: Job
          metadata:
            namespace: default
            generateName: hellojob-
            annotations:
              sidecar.istio.io/inject: "false"
          spec:
            template:
              metadata:
                annotations:
                  sidecar.istio.io/inject: "false"
              spec:
                volumes:
                  - emptyDir: {}
                    name: cali-mount
                containers:
                  - name: export-tenant
                    image: centos:7
                    command: [sh, -c]
                    args: ["echo 'some result' > /command_output/result.txt; cat /command_output/result.txt; sleep 5; echo done; exit 0"]
                    env:
                      - name: message
                        value: "{{inputs.parameters.message}}"
                      - name: previous_step_output
                        value: "{{inputs.parameters.previous_step_output}}"
                    volumeMounts:
                      - mountPath: /command_output
                        name: cali-mount
                restartPolicy: Never
      outputs:
        parameters:
          - name: job-name
            valueFrom:
              jsonPath: '{.metadata.name}'
          - name: job-obj
            valueFrom:
              jqFilter: '.'
          - name: previous_step_output
            valueFrom:
              path: /command_output/result.txt
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: outer-template
  namespace: cali
  labels:
    workflows.argoproj.io/controller-instanceid: cali
spec:
  entrypoint: HelloWorld
  templates:
    - name: HelloWorld
      inputs:
        parameters:
          - name: message
      steps:
        - - name: step-1
            templateRef:
              name: inner-template
              template: InnerJob
            arguments:
              parameters:
                - name: message
                  value: "{{inputs.parameters.message}}"
        - - name: step-2
            templateRef:
              name: inner-template
              template: InnerJob
            arguments:
              parameters:
                - name: message
                  value: "{{inputs.parameters.message}}"
                - name: previous_step_output
                  value: "{{steps.step-1.outputs.parameters.previous_step_output}}"

请求负载:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-
  namespace: cali
  labels:
    workflows.argoproj.io/controller-instanceid: cali
spec:
  entrypoint: HelloWorld
  serviceAccountName: argo
  templates:
      - name: HelloWorld
        steps:
          - - name: init-step
              arguments:
                parameters:
                  - name: message
                    value: "Hello World....."
              templateRef:
                name: outer-template
                template: HelloWorld

据我所知,Argo Workflows resource templates不支持读取文件作为输出参数。

看起来从 job 资源到实例化工作流的唯一内置方法是通过 job 资源本身的 JSON 表示。

我建议在工作流中将作业转换为普通容器模板。然后您可以使用所有典型的通信方法(直接从标准输出读取、将文件读入输出参数、读取输出工件等)。