argoproj / argo-workflows

Workflow Engine for Kubernetes
https://argo-workflows.readthedocs.io/
Apache License 2.0
15k stars 3.2k forks source link

Enable Outputs on a Workflow Level #2784

Open ericmeadows opened 4 years ago

ericmeadows commented 4 years ago

Summary

Enable Workflows to have outputs that can be sourced from steps, including onExit, and can get values from nested Workflow Templates by their step names.

Motivation

I would like to understand what builds ran that had under 75% code coverage, which have high code smells (SonarLint/SonarQube), what my average build cost is per build per user (see https://github.com/argoproj/argo/issues/2783).

Proposal

I would like all builds to have outputs be enabled, and configurable.


Message from the maintainers:

If you wish to see this enhancement implemented please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.

louiscpalma commented 4 years ago

I've been looking for similar functionality in Argo and ultimately resorted to using global outputs as a workaround. I don't believe this works for onExit steps though, and also becomes problematic with templated steps since they can't share the same globalName.

Luckily this is sufficient for my use-case right now, but can see this becoming a problem in the future:

Example Workflow

---
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: issue2748
  namespace: argo
spec:
  serviceAccountName: argo
  entrypoint: main
  onExit: exit-handler

  templates:
  - name: main
    steps:
    - - name: first
        template: sample
    - - name: second
        template: sample

  - name: sample
    container:
      image: debian:buster-slim
      command: [sh, -c]
      args: ['echo "some data from ${HOSTNAME}" |tee /tmp/data.txt']
    outputs: 
      parameters:
      - name: data
        valueFrom:
          path: /tmp/data.txt
        globalName: my-data

  - name: exit-handler
    container:
      image: debian:buster-slim
      command: [sh, -c]
      args: ['echo {{main.steps.first.outputs.parameters.data}}'] # Cannot find reference

### WORKAROUND ###      
# will be overwritten with main.second.outputs.parameters.data
# args: ['echo {{workflow.outputs.parameters.my-data}}']

Expected output

issue2748-4230798355: some data from issue2748-4230798355
issue2748-1574821332: some data from issue2748-1574821332
issue2748-1438237774: some data from issue2748-4230798355

Returned output

issue2748-4230798355: some data from issue2748-4230798355
issue2748-1574821332: some data from issue2748-1574821332
issue2748-1438237774: {{main.steps.first.output.parameters.data}}