-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workflow and Template status change notification/trigger using Lifecycle Hook #7073
Closed
Tracked by
#6943
Labels
Comments
sarabala1979
changed the title
Lifecycle status update Hook for workflow and Template state update
Workflow and Template state notification/trigger using Lifecycle Hook
Oct 27, 2021
sarabala1979
changed the title
Workflow and Template state notification/trigger using Lifecycle Hook
Workflow and Template status change notification/trigger using Lifecycle Hook
Oct 27, 2021
Just a thought: make consistent with pod hooks: https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/ |
Sample workflow apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: lifecycle-hook-
spec:
entrypoint: diamond
hooks:
running:
expression: "{{workflow.status}} == Running"
template: http
templates:
- name: diamond
dag:
tasks:
- name: A
hooks:
exit:
template: http
success:
expression: "{{tasks.A.status}} == Succeeded"
template: http
failure:
expression: "{{tasks.A.status}} == Failed"
template: http
error:
expression: "{{tasks.A.status}} == Error"
template: http
template: coinflip
- name: B
hooks:
success:
expression: "{{tasks.B.status}} == Succeeded"
template: http
depends: "A"
template: coinflip
- name: C
hooks:
success:
expression: "{{tasks.C.status}} == Succeeded"
template: heads
depends: "A"
template: coinflip
- name: D
hooks:
success:
expression: "{{tasks.D.status}} == Succeeded"
template: heads
depends: "B && C"
template: coinflip
- name: coinflip
steps:
# - - name: flip-coin-1
# template: prestart
- - name: flip-coin
hooks:
success:
expression: "{{steps.flip-coin.status}} == Succeeded"
template: http
condition:
expression: "{{steps.flip-coin.status}} == Succeeded"
template: http
template: flip-coin
- - name: heads
hooks:
success:
expression: "{{steps.flip-coin.outputs.result}} == heads"
template: heads
template: http
when: "{{steps.flip-coin.outputs.result}} == heads"
- name: tails
template: heads
when: "{{steps.flip-coin.outputs.result}} == tails"
- name: flip-coin
script:
image: python:alpine3.6
command: [python]
source: |
import random
result = "heads" if random.randint(0,1) == 0 else "tails"
print(result)
- name: heads
container:
image: alpine:3.6
command: [sh, -c]
args: ["echo \"it was heads\""]
- name: http
http:
# url: http://dummy.restapiexample.com/api/v1/employees
url: "https://raw.githubusercontent.com/argoproj/argo-workflows/4e450e250168e6b4d51a126b784e90b11a0162bc/pkg/apis/workflow/v1alpha1/generated.swagger.json" |
Fixed I think? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
Inspiration from #4355. We can add workflow and template lifecycle hook
Example:
Lifecycle hook (Workflow level and Template level)
Option 1:
Option2:
The text was updated successfully, but these errors were encountered: