简体   繁体   English

当我使用带有 withParam 循环的条件以及工件输入时,Argo 工作流模板执行失败

[英]Argo workflow template execution failing when I use when condition with withParam loop along with the artifact input

I've the following workflow template which has when condition when: "'{{item}}' =~ '^tests/'" , artifacts input as file path in AWS S3 bucket and withParam loop.我有以下工作流模板,它具有以下条件when: "'{{item}}' =~ '^tests/'" ,工件作为 AWS S3存储桶中的文件路径和withParam循环输入。

Here is my workflow template这是我的工作流程模板

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: process-wft
spec:
  entrypoint: main
  templates:
    - name: main
      inputs:
        parameters:
          - name: dir-process
            default: true
          - name: dir


        artifacts:
          - name: Code

      dag:
        tasks:
          - name: process-wft-tests
            when: "'{{item}}' =~ '^tests/'"
            templateRef:
              name: tf-wf-rn
              template: main
            arguments:
              parameters:
                - name: dir-process
                  value: "{{inputs.parameters.dir-process}}"
              artifacts:
                - name: Code
                  from: "{{inputs.artifacts.Code}}"
            withParam: "{{inputs.parameters.dir}}"

here is my input artifact Code extracted result which is being passed from my workflow这是我的输入工件Code提取结果,它是从我的工作流程传递的

inputs:
  artifacts:
  - archive:
      tar:
        compressionLevel: 9
    archiveLogs: true
    globalName: GitSource
    name: Code
    path: /mnt/out/code
    s3:
      key: process-kfxqf/process-kfxqf-1938174407/GitSource.tgz

It is giving the below Error when I run my workflow当我运行我的工作流程时,它给出了以下错误

message: failed to resolve {{inputs.artifacts.Code}}

What's the mistake am doing here?我在这里做错了什么? if it doesn't work what's the alternate way to get this worked?如果它不起作用,那么另一种方法是什么?

Note: I tried workflow execution by removing when condition, it is working fine.注意:我尝试通过删除 when 条件来执行工作流,它工作正常。 It is giving issue only when I add when condition.只有当我添加条件时才会出现问题。

This is a bug .这是一个错误

It seems that when the condition evaluates to false , some code skips populating the artifact (makes sense, save some time), but some other code doesn't respect the when condition and still expects the artifact to be populated.似乎当条件评估为false时,一些代码会跳过填充工件(有意义,节省一些时间),但其他一些代码不尊重when条件,仍然希望填充工件。

Potential workarounds:潜在的解决方法:

  1. Move the conditional logic into the container.将条件逻辑移动到容器中。

    1. remove the when condition删除when条件
    2. pass the dir parameter to the main template in your tf-wf-rn WorkflowTemplatedir参数传递给tf-wf-rn WorkflowTemplate 中的main模板
    3. change the main template to run the regex against the dir parameter - if it doesn't match, just exit 0更改main模板以针对dir参数运行正则表达式 - 如果不匹配,则退出 0

    This could make the workflow much slower, because you'll have to spin up a pod for each iteration of the loop to determine if there's actually any work to be done.这可能会使工作流程变得更慢,因为您必须为循环的每次迭代启动一个 pod 以确定是否实际上有任何工作要做。

  2. If you can calculate all the information about the artifact, pass that information as parameters to the main template in your tf-wf-rn WorkflowTemplate.如果您可以计算有关工件的所有信息,请将这些信息作为参数传递给tf-wf-rn WorkflowTemplate 中的main模板。 Then actually load the artifact in that non-conditioned, non-looped template.然后在那个无条件、无循环的模板中实际加载工件。 (Basically hopscotch over the problematic code.) (基本上是跳过有问题的代码。)

  3. Try an older version.尝试旧版本。

    If you find a working older version, please 1) comment on the bug report and 2) make sure the older version doesn't have any relevant security vulnerabilities before running it on a production system.如果您发现一个可以工作的旧版本,请 1) 对错误报告发表评论,并且 2) 在生产系统上运行旧版本之前,请确保它没有任何相关的安全漏洞。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM