Skip to content
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

fix: Synchronization lock handling in Step/DAG Template level #5081

Merged
merged 9 commits into from
Feb 12, 2021
10 changes: 10 additions & 0 deletions docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,8 @@ Synchronization holds synchronization lock configuration
- [`synchronization-tmpl-level.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/synchronization-tmpl-level.yaml)

- [`synchronization-wf-level.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/synchronization-wf-level.yaml)

- [`templates.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/workflow-template/templates.yaml)
</details>

### Fields
Expand Down Expand Up @@ -2173,6 +2175,8 @@ SynchronizationStatus stores the status of semaphore and mutex.
- [`synchronization-tmpl-level.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/synchronization-tmpl-level.yaml)

- [`synchronization-wf-level.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/synchronization-wf-level.yaml)

- [`templates.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/workflow-template/templates.yaml)
</details>

### Fields
Expand Down Expand Up @@ -2507,6 +2511,8 @@ SemaphoreRef is a reference of Semaphore
- [`synchronization-tmpl-level.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/synchronization-tmpl-level.yaml)

- [`synchronization-wf-level.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/synchronization-wf-level.yaml)

- [`templates.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/workflow-template/templates.yaml)
</details>

### Fields
Expand Down Expand Up @@ -3192,6 +3198,8 @@ _No description available_
- [`synchronization-tmpl-level.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/synchronization-tmpl-level.yaml)

- [`synchronization-wf-level.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/synchronization-wf-level.yaml)

- [`templates.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/workflow-template/templates.yaml)
</details>

### Fields
Expand Down Expand Up @@ -4652,6 +4660,8 @@ Selects a key from a ConfigMap.
- [`synchronization-tmpl-level.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/synchronization-tmpl-level.yaml)

- [`synchronization-wf-level.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/synchronization-wf-level.yaml)

- [`templates.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/workflow-template/templates.yaml)
</details>

### Fields
Expand Down
5 changes: 5 additions & 0 deletions examples/steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ spec:
entrypoint: hello-hello-hello
templates:
- name: hello-hello-hello
synchronization:
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved
semaphore:
configMapKeyRef:
key: template
name: my-config
steps:
- - name: hello1
template: whalesay
Expand Down
5 changes: 5 additions & 0 deletions examples/workflow-template/templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ spec:
command: [cowsay]
args: ["{{inputs.parameters.message}}"]
- name: inner-steps
synchronization:
semaphore:
configMapKeyRef:
name: my-config
key: template
steps:
- - name: inner-hello1
templateRef:
Expand Down
6 changes: 6 additions & 0 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,12 @@ func (woc *wfOperationCtx) executeTemplate(ctx context.Context, nodeName string,
}
}

if node.Fulfilled() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the right place to check the node status and release the lock.

if processedTmpl.Synchronization != nil {
sarabala1979 marked this conversation as resolved.
Show resolved Hide resolved
woc.controller.syncManager.Release(woc.wf, node.ID, processedTmpl.Synchronization)
}
}

if processedTmpl.Metrics != nil {
// Check if the node was just created, if it was emit realtime metrics.
// If the node did not previously exist, we can infer that it was created during the current operation, emit real time metrics.
Expand Down
Loading