How to skip a step for Argo workflow
Asked Answered
S

1

7

I'm trying out Argo workflow and would like to understand how to freeze a step. Let's say that I have 3 step workflow and a workflow failed at step 2. So I'd like to resubmit the workflow from step 2 using successful step 1's artifact. How can I achieve this? I couldn't find the guidance anywhere on the document.

Stipitate answered 2/7, 2019 at 2:25 Comment(0)
S
4

I think you should consider using Conditions and Artifact passing in your steps.

Conditionals provide a way to affect the control flow of a workflow at runtime, depending on parameters. In this example the 'print-hello' template may or may not be executed depending on the input parameter, 'should-print'. When submitted with

$ argo submit examples/conditionals.yaml

the step will be skipped since 'should-print' will evaluate false. When submitted with:

$ argo submit examples/conditionals.yaml -p should-print=true

the step will be executed since 'should-print' will evaluate true.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: conditional-
spec:
  entrypoint: conditional-example
  arguments:
    parameters:
    - name: should-print
      value: "false"

  templates:
  - name: conditional-example
    inputs:
      parameters:
      - name: should-print
    steps:
    - - name: print-hello
        template: whalesay
        when: "{{inputs.parameters.should-print}} == true"

  - name: whalesay
    container:
      image: docker/whalesay:latest
      command: [sh, -c]
      args: ["cowsay hello"]

If you use conditions in each step you will be able to start from a step you like with appropriate condition.

Also have a loot at this article Argo: Workflow Engine for Kubernetes as author explains the use of conditions on coinflip example. You can see many examples on their GitHub page.

Spireme answered 2/7, 2019 at 9:19 Comment(4)
Thanks for the comment :) I know conditionals but would it be possible to use artifacts created from a different run (such as artifact from a previously failed one)?Stipitate
You mean using a failed workflow artifact inside new workflow?Spireme
It'd like to take the failed workflow and use a different image to restart from the specific step that failed. So that I don't have to run previous steps that were successful over and over again.Stipitate
I don't know, but I don't think this should be possible. The workflow failed and it should not be possible to use artifacts from that workflow in a new workflow especially when the image changes.Spireme

© 2022 - 2024 — McMap. All rights reserved.