Skip to content

Omitted node's failure hook runsΒ #15192

@isubasinghe

Description

@isubasinghe

Pre-requisites

  • I have double-checked my configuration
  • I have tested with the :latest image tag (i.e. quay.io/argoproj/workflow-controller:latest) and can confirm the issue still exists on :latest. If not, I have explained why, in detail, in my description below.
  • I have searched existing issues and could not find a match for this bug
  • I'd like to contribute the fix myself (see contributing guide)

What happened? What did you expect to happen?

When you submit a workflow with a failure hook, it should only run when the node has failed.
For some reason the dag engine handles hooks differently when they are the leaf node. In the provided example below the D task is omitted but the failure hook runs anyway.

Version(s)

latest

Paste a minimal workflow that reproduces the issue. We must be able to run the workflow; don't enter a workflow that uses private images.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: dag-diamond-hooks-
spec:
  entrypoint: main
  templates:
    - name: main
      dag:
        tasks:
          - name: A
            template: worker
            hooks:
              failure:
                expression: "true" # Required by some 'main' branch builds
                template: notifier
                arguments:
                  parameters: [{name: task-id, value: "Node A"}]

          - name: B
            depends: "A"
            template: worker
            hooks:
              failure:
                expression: "true"
                template: notifier
                arguments:
                  parameters: [{name: task-id, value: "Node B"}]

          - name: C
            depends: "A"
            template: worker
            hooks:
              failure:
                expression: "true"
                template: notifier
                arguments:
                  parameters: [{name: task-id, value: "Node C"}]

          - name: D
            depends: "B && C"
            template: worker
            hooks:
              failure:
                expression: "true"
                template: notifier
                arguments:
                  parameters: [{name: task-id, value: "Node D"}]

    - name: worker
      container:
        image: alpine:latest
        command: [sh, -c]
        args: ["if [ $(($RANDOM % 2)) -eq 0 ]; then echo 'Success'; exit 0; else echo 'Failing'; exit 1; fi"]

    - name: notifier
      inputs:
        parameters:
          - name: task-id
      container:
        image: alpine:latest
        command: [echo]
        args: ["ALERT: Task '{{inputs.parameters.task-id}}' failed."]

Logs from the workflow controller

not needed

Logs from in your workflow's wait container

not needed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions