Skip to content

Commit

Permalink
feat(operator): Add hostNodeName as a template variable (#10950)
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Oren <amit@coralogix.com>
  • Loading branch information
amit-o authored Apr 24, 2023
1 parent 51c066f commit 2401be8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions USERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Currently, the following organizations are **officially** using Argo Workflows:
1. [Commodus Tech](https://www.commodus.tech)
1. [Concierge Render](https://www.conciergerender.com)
1. [Cookpad](https://cookpad.com/)
1. [Coralogix](https://coralogix.com)
1. [CoreFiling](https://www.corefiling.com/)
1. [CoreWeave Cloud](https://www.coreweave.com)
1. [Cratejoy](https://www.cratejoy.com/)
Expand Down
2 changes: 2 additions & 0 deletions docs/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ returns `0`. Please review the Sprig documentation to understand which functions
| `steps.<STEPNAME>.exitCode` | Exit code of any previous script or container step |
| `steps.<STEPNAME>.startedAt` | Time-stamp when the step started |
| `steps.<STEPNAME>.finishedAt` | Time-stamp when the step finished |
| `steps.<TASKNAME>.hostNodeName` | Host node where task ran |
| `steps.<STEPNAME>.outputs.result` | Output result of any previous container or script step |
| `steps.<STEPNAME>.outputs.parameters` | When the previous step uses `withItems` or `withParams`, this contains a JSON array of the output parameter maps of each invocation |
| `steps.<STEPNAME>.outputs.parameters.<NAME>` | Output parameter of any previous step. When the previous step uses `withItems` or `withParams`, this contains a JSON array of the output parameter values of each invocation |
Expand All @@ -159,6 +160,7 @@ returns `0`. Please review the Sprig documentation to understand which functions
| `tasks.<TASKNAME>.exitCode` | Exit code of any previous script or container task |
| `tasks.<TASKNAME>.startedAt` | Time-stamp when the task started |
| `tasks.<TASKNAME>.finishedAt` | Time-stamp when the task finished |
| `tasks.<TASKNAME>.hostNodeName` | Host node where task ran |
| `tasks.<TASKNAME>.outputs.result` | Output result of any previous container or script task |
| `tasks.<TASKNAME>.outputs.parameters` | When the previous task uses `withItems` or `withParams`, this contains a JSON array of the output parameter maps of each invocation |
| `tasks.<TASKNAME>.outputs.parameters.<NAME>` | Output parameter of any previous task. When the previous task uses `withItems` or `withParams`, this contains a JSON array of the output parameter values of each invocation |
Expand Down
4 changes: 4 additions & 0 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2829,6 +2829,10 @@ func (woc *wfOperationCtx) buildLocalScope(scope *wfScope, prefix string, node *
key := fmt.Sprintf("%s.status", prefix)
scope.addParamToScope(key, string(node.Phase))
}
if node.HostNodeName != "" {
key := fmt.Sprintf("%s.hostNodeName", prefix)
scope.addParamToScope(key, string(node.HostNodeName))
}
woc.addOutputsToLocalScope(prefix, node.Outputs, scope)
}

Expand Down
2 changes: 2 additions & 0 deletions workflow/controller/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4001,6 +4001,7 @@ status:
cpu: 10
memory: 0
startedAt: "2020-04-02T16:29:18Z"
hostNodeName: ip-127-0-1-1
templateName: influxdb
type: Pod
daemon-step-dvbnn-3639466923:
Expand Down Expand Up @@ -4044,6 +4045,7 @@ func TestRetryNodeOutputs(t *testing.T) {
assert.Contains(t, scope.scope, "steps.influx.id")
assert.Contains(t, scope.scope, "steps.influx.startedAt")
assert.Contains(t, scope.scope, "steps.influx.finishedAt")
assert.Contains(t, scope.scope, "steps.influx.hostNodeName")
}

var workflowWithPVCAndFailingStep = `
Expand Down
1 change: 1 addition & 0 deletions workflow/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ func (ctx *templateValidationCtx) addOutputsToScope(tmpl *wfv1.Template, prefix
scope[fmt.Sprintf("%s.id", prefix)] = true
scope[fmt.Sprintf("%s.startedAt", prefix)] = true
scope[fmt.Sprintf("%s.finishedAt", prefix)] = true
scope[fmt.Sprintf("%s.hostNodeName", prefix)] = true
if tmpl.Daemon != nil && *tmpl.Daemon {
scope[fmt.Sprintf("%s.ip", prefix)] = true
}
Expand Down
7 changes: 7 additions & 0 deletions workflow/validate/validate_dag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ spec:
- name: startedat
- name: finishedat
- name: id
- name: hostnodename
container:
image: alpine:3.7
command: [echo, "{{inputs.parameters.message}}"]
Expand All @@ -166,6 +167,8 @@ spec:
value: "test"
- name: id
value: "1"
- name: hostnodename
value: "test"
- name: B
dependencies: [A]
template: echo
Expand All @@ -179,6 +182,8 @@ spec:
value: "{{tasks.A.finishedAt}}"
- name: id
value: "{{tasks.A.id}}"
- name: hostnodename
value: "{{tasks.A.hostNodeName}}"
- name: C
dependencies: [B]
template: echo
Expand All @@ -192,6 +197,8 @@ spec:
value: "{{tasks.A.finishedAt}}"
- name: id
value: "{{tasks.A.id}}"
- name: hostnodename
value: "{{tasks.A.hostNodeName}}"
`

var dagResolvedVarNotAncestor = `
Expand Down

0 comments on commit 2401be8

Please sign in to comment.