Skip to content

Commit

Permalink
feat: lifecycle hook (#7582)
Browse files Browse the repository at this point in the history
* feat: ls
hook

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: files

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: codegen

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: unwanted code

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: unwanted code

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: lint and test

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: address comments

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: address comments

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: removed printf

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: fixed

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: lint

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: expr envmap

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: added test

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: test

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: test

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: line

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: lint

Signed-off-by: Saravanan Balasubramanian <[email protected]>

* fix: lint

Signed-off-by: Saravanan Balasubramanian <[email protected]>
  • Loading branch information
sarabala1979 authored Jan 28, 2022
1 parent 303bf79 commit 45730a9
Show file tree
Hide file tree
Showing 38 changed files with 6,857 additions and 740 deletions.
18 changes: 18 additions & 0 deletions api/jsonschema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5518,6 +5518,10 @@
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Arguments",
"description": "Arguments hold arguments to the template"
},
"expression": {
"description": "Expression is a condition expression for when a node will be retried. If it evaluates to false, the node will not be retried and the retry strategy will be ignored",
"type": "string"
},
"template": {
"description": "Template is the name of the template to execute by the hook",
"type": "string"
Expand Down Expand Up @@ -7416,6 +7420,13 @@
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.ExecutorConfig",
"description": "Executor holds configurations of executor containers of the io.argoproj.workflow.v1alpha1."
},
"hooks": {
"additionalProperties": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.LifecycleHook"
},
"description": "Hooks holds the lifecycle hook which is invoked at lifecycle of step, irrespective of the success, failure, or error status of the primary step",
"type": "object"
},
"hostAliases": {
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.HostAlias"
Expand Down Expand Up @@ -7932,6 +7943,13 @@
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.ExecutorConfig",
"description": "Executor holds configurations of executor containers of the io.argoproj.workflow.v1alpha1."
},
"hooks": {
"additionalProperties": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.LifecycleHook"
},
"description": "Hooks holds the lifecycle hook which is invoked at lifecycle of step, irrespective of the success, failure, or error status of the primary step",
"type": "object"
},
"hostAliases": {
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.HostAlias"
Expand Down
18 changes: 18 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -9784,6 +9784,10 @@
"description": "Arguments hold arguments to the template",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Arguments"
},
"expression": {
"description": "Expression is a condition expression for when a node will be retried. If it evaluates to false, the node will not be retried and the retry strategy will be ignored",
"type": "string"
},
"template": {
"description": "Template is the name of the template to execute by the hook",
"type": "string"
Expand Down Expand Up @@ -11661,6 +11665,13 @@
"description": "Executor holds configurations of executor containers of the io.argoproj.workflow.v1alpha1.",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.ExecutorConfig"
},
"hooks": {
"description": "Hooks holds the lifecycle hook which is invoked at lifecycle of step, irrespective of the success, failure, or error status of the primary step",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.LifecycleHook"
}
},
"hostAliases": {
"type": "array",
"items": {
Expand Down Expand Up @@ -12168,6 +12179,13 @@
"description": "Executor holds configurations of executor containers of the io.argoproj.workflow.v1alpha1.",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.ExecutorConfig"
},
"hooks": {
"description": "Hooks holds the lifecycle hook which is invoked at lifecycle of step, irrespective of the success, failure, or error status of the primary step",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.LifecycleHook"
}
},
"hostAliases": {
"type": "array",
"items": {
Expand Down
155 changes: 101 additions & 54 deletions docs/fields.md

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions examples/life-cycle-hooks-tmpl-level.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: lifecycle-hook-tmpl-level-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: step-1
hooks:
exit:
# Expr will not support `-` on variable name. Variable should wrap with `[]`
expression: steps["step-1"].status == "Running"
template: http
success:
expression: steps["step-1"].status == "Succeeded"
template: http
template: echo
- - name: step2
hooks:
exit:
expression: steps.step2.status == "Running"
template: http
success:
expression: steps.step2.status == "Succeeded"
template: http
template: echo

- name: echo
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"
28 changes: 28 additions & 0 deletions examples/life-cycle-hooks-wf-level.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: lifecycle-hook-
spec:
entrypoint: main
hooks:
exit:
template: http
running:
expression: workflow.status == "Running"
template: http
templates:
- name: main
steps:
- - name: step1
template: heads

- 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"
Loading

0 comments on commit 45730a9

Please sign in to comment.