Skip to content

Conversation

@juanxiu
Copy link

@juanxiu juanxiu commented Sep 11, 2025

onExit handlers can now reference DAG task outputs using {{workflow.outputs.parameters.*}}

  • Add global parameter update before onExit handler execution
  • Allow workflow.outputs.parameters.* references in validation logic
  • Update checkValidWorkflowVariablePrefix, resolveAllVariables, and VerifyResolvedVariables
  • Enable onExit handlers to access DAG task outputs without YAML modifications

Fixes #14767

Motivation

In Argo Workflows, the onExit handler cannot access DAG task outputs through workflow.outputs.parameters.*. Due to this limitation, users are unable to implement cleanup or notification logic that depends on the results of DAG task executions.

Modifications

1. Runtime Logic

  • Update workflow outputs to global variables before executing the onExit handler

2. Validation Logic

  • Ensure that the workflow.outputs.parameters.* pattern is valid across different validation paths

Verification

validation and runtime execution both pass successfully

1. Submission-time Validation Test

  • Dry-run (validation only)
./dist/argo submit --dry-run -o yaml --from workflowtemplate/dag-template-exit-outputs -n argo -p namespace=argo

Expected Result: YAML output (validation passes)
Failure Case: failed to resolve {{workflow.outputs.parameters.foo-replicas}} error

2. Runtime Execution Test

  • Actual workflow execution
./dist/argo submit --from workflowtemplate/dag-template-exit-outputs -n argo -p namespace=argo

  • Wait for workflow completion
kubectl wait --for=condition=completed workflow/[WORKFLOW_NAME] -n argo --timeout=60s
  • Check logs
kubectl logs -n argo -l workflows.argoproj.io/workflow=[WORKFLOW_NAME] --tail=10

Expected Result: Exit handler can access: task output
Failure Case: Exit handler can access: (empty value)

Documentation

Example yaml

yaml
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: data-processing-with-cleanup
spec:
  entrypoint: main
  onExit: cleanup-handler
  templates:
  - name: main
    dag:
      tasks:
      - name: process-data
        template: data-processor
      - name: generate-report
        template: report-generator
        dependencies: [process-data]
  - name: data-processor
    container:
      image: python:3.9
      command: [python, -c]
      args: ["import json; print(json.dumps({'status': 'success', 'records': 1000})) > /tmp/result.json"]
    outputs:
      parameters:
      - name: processing-status
        globalName: data-status
        valueFrom:
          path: /tmp/result.json
  - name: cleanup-handler
    container:
      image: alpine:latest
      command: [sh, -c]
      args: ["echo 'Cleanup completed. Processing status: {{workflow.outputs.parameters.data-status}}'"]

@juanxiu juanxiu force-pushed the fix/onexit-global-params-access branch from 540acfb to 01420a1 Compare September 11, 2025 06:53
…outputs.parameters

- Add global parameter update before onExit handler execution in operator.go
- Allow workflow.outputs.parameters.* references in validation logic
- Update checkValidWorkflowVariablePrefix, resolveAllVariables, and VerifyResolvedVariables
- Enable onExit handlers to access DAG task outputs without YAML modifications

Fixes: onExit handlers can now reference DAG task outputs using {{workflow.outputs.parameters.*}}
Tested: validation and runtime execution both pass successfully
Signed-off-by: yeonsoo <[email protected]>
@juanxiu juanxiu force-pushed the fix/onexit-global-params-access branch from 01420a1 to 85261a9 Compare September 11, 2025 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to set / access global output using DAG workflow and onExit handler

1 participant