jsonyamlargo-workflows

How can I pass a list to child Argo Workflow via the Workflow of Workflow pattern


I'm currently thinking of utilizing the workflow of workflow pattern for a design of a workflow that takes a list, batches that list and submits each batch to a generated workflow - idea is I can finely control the level of parallelism and success/failure conditions between workflows.

I'm at the point where I'm submitting the list as an arugment with the resource template pointed at a WorkflowTemplate that should be taking that list and then using withParam to run with it, however the input param is coming up null

I've confirmed this using the example from the Workflow of Workflows pattern doc - the input parameter message will be null (not the default value) in the generated workflows

Is this expected? Is my design not ideal?

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: workflow-template-submittable
spec:
  entrypoint: whalesay-template
  arguments:
    parameters:
      - name: message
        value: hello world
  templates:
    - name: whalesay-template
      inputs:
        parameters:
          - name: message
      container:
        image: docker/whalesay
        command: [cowsay]
        args: ["{{inputs.parameters.message}}"]
---
# This template demonstrates a workflow of workflows.
# Workflow triggers one or more workflows and manages them.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: workflow-of-workflows-
spec:
  entrypoint: main
  templates:
    - name: main
      steps:
        - - name: workflow2
            template: resource-with-argument
            arguments:
              parameters:
                - name: workflowtemplate
                  value: "workflow-template-submittable"
                - name: message
                  value: |
                    [
                      { "image": "debian", "tag": "9.1" },
                      { "image": "debian", "tag": "8.9" },
                      { "image": "alpine", "tag": "3.6" },
                      { "image": "ubuntu", "tag": "17.10" }
                    ]
    - name: resource-with-argument
      inputs:
        parameters:
          - name: workflowtemplate
          - name: message
      resource:
        action: create
        manifest: |
          apiVersion: argoproj.io/v1alpha1
          kind: Workflow
          metadata:
            generateName: workflow-of-workflows-2-
          spec:
            arguments:
              parameters:
              - name: message
                value: {{inputs.parameters.message}}
            workflowTemplateRef:
              name: {{inputs.parameters.workflowtemplate}}
        successCondition: status.phase == Succeeded
        failureCondition: status.phase in (Failed, Error)


Solution

  • I was able to resolve via the sprig expr toJson() then it'd submit appropriately - this is likely due to my misunderstanding between a JSON encoded string and a JSON obj, the former is what can be passed between workflows.

    The essential piece of the updated Workflow:

          resource:
            action: create
            manifest: |
              apiVersion: argoproj.io/v1alpha1
              kind: Workflow
              metadata:
                generateName: workflow-of-workflows-2-
              spec:
                arguments:
                  parameters:
                  - name: message
                    value: {{=ToJSON(inputs.parameters.message)}}
                workflowTemplateRef:
                  name: {{inputs.parameters.workflowtemplate}}
            successCondition: status.phase == Succeeded
            failureCondition: status.phase in (Failed, Error)