-
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
feat: Added onExit handlers to arbitrary templates #1716
Conversation
Implementation is now done and should be ready for review.
Output:
Output:
|
@simster7 Leaf node exit handler may need access to Node status to be able to use "when" conditions. If an exit handler is configured for a node can the node status be made available globally similar to workflow.status? something like below, nodeid := fmt.Sprintf("templates.%s.tasks.%s.status",tmpl.Name, name) I think same applies for per template exit handler, it may need access to that template status. |
@mak-454 If you're looking for a way to run a template conditionally after another, you can always create a |
@simster7 I was referring to an example similar like exit-handlers |
@mak-454 I see what you're saying now, sorry for the misunderstanding. Let me think about this. |
@simster7 no issues :) |
@mak-454 I think what your request boils down to is to expose a |
@simster7 ok will create a separate issue. |
@simster7 any idea if this is going to merge in the coming release? |
This change will be released soon with workflow templates refactoring. We are planning to release v2.4.3 last week of November |
@simster7 Thank you for adding the more granular What do you think? |
Hey @Ark-kun, thank you for your comment. I am inclined to agree with you. Here is a bit of my thought process. As a whole, I think For example: ...
spec:
entrypoint: whalesay
templates:
- name: whalesay
onExit: exitContainer
container:
...
- name: exitContainer
container:
... Is really a shorthand for: ...
spec:
entrypoint: whalesay
templates:
- name: onExitWhalesay
steps:
- - name: whalesay
template: whalesay
continueOn:
failed: true
error: true
- - name: onExit
template: exitContainer
- name: whalesay
container:
...
- name: exitContainer
container:
... Since Your suggestion is on the middle of the two; we would essentially be trading convenience for some edge cases for a more consistent design. I am inclined to say that it's worth the trade-off, but others may feel it's up for discussion. What I can say with certainty is that the design of this feature is not set in stone and still has to go through some internal discussions. I will certainly be bringing this up when they happen after KubeCon. |
@simster7 thanks for the explanation. I see one merit in moving
|
BTW, This issue proposes a more capable replacement for |
Update: After a discussion we have decided to go with the approach suggested by @Ark-kun and move the |
The refactor is complete. Example: apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: container-on-exit-
spec:
entrypoint: step-template
templates:
- name: step-template
steps:
- - name: stepA
onExit: exitContainer
template: whalesay
- - name: stepB
onExit: exitContainer
template: whalesay
- name: whalesay
container:
image: docker/whalesay
command: [cowsay]
args: ["hello world"]
- name: exitContainer
container:
image: docker/whalesay
command: [cowsay]
args: ["goodbye world"]
---
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: dag-diamond-
spec:
entrypoint: diamond
templates:
- name: diamond
dag:
tasks:
- name: A
template: whalesay
onExit: exitContainer
- name: B
dependencies: [A]
template: whalesay
onExit: exitContainer
- name: C
dependencies: [A]
template: whalesay
onExit: exitContainer
- name: D
dependencies: [B, C]
template: whalesay
onExit: exitContainer
- name: whalesay
container:
image: docker/whalesay
command: [cowsay]
args: ["hello world"]
- name: exitContainer
container:
image: docker/whalesay
command: [cowsay]
args: ["goodbye world"] |
@alexec @sarabala1979 Can I get another review on this since the code was refactored? |
@sarabala1979 as you've more experience and have already commented - can I ask you to review this please? |
Changed the code to use correct template contexts. |
Fixes: #1688. Added onExit handlers to any template.
Example:
Output:
TODO: