-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: multiple mutexes and semaphores
Fixes #5022 Fixes #11859 This is mostly backwards compatbile. It is minorly breaking only in as much as semaphore + mutex at the same time will now require both, whereas before it ignored the mutex. As a workflows users I would like to be able to use more than one sync option in a workflow or template. Added `mutexes` and `semaphores` to the `synchronization` block in workflow types as lists. Legacy `mutex` and `semaphore` kept in and continue to work (will be added to the mutexes/semaphores list) but marked for deprecation. Logic changed to acquire a full list of all synchronization items (`syncItem`) when `TryAcquire` and `Release` from sync manager. `TryAcquire` from sync_manager` calls a new `checkAcquire` method, whilst holding the sync_manager internal golang `sync.Mutex` to check if they are all acquirable before acquiring them. This honors priority. `TryAcquire` also returns the failed lock name in the case of failure to acquire to reduce the number of exported `package sync` methods and complexity outside of `sync`. The interface to the workflow status block has not changed. Reduced the exported types and methods from the sync module as far as possible (lower case instead of upper case). Removed the internal golang sync mutex from `PrioritySemaphore` as all methods are called from `sync_manager.go` when under it's own lock. The alternative was unnecessarily complicating the calls inside semaphore.go. This is faster, but less clean in case someone wants to reuse the PrioritySemaphore type. Renamed the manager in `sync_manager.go` where used: `cm`->`sm` and `concurrencyManager`->`syncManager`. New and updated unit tests. New and updated e2e smoke tests. Signed-off-by: Alan Clucas <[email protected]>
- Loading branch information
Showing
55 changed files
with
3,428 additions
and
1,188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,6 +183,7 @@ memoizing | |
metadata | ||
minikube | ||
mutex | ||
mutexes | ||
namespace | ||
namespaces | ||
natively | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Limiting parallelism | ||
|
||
You can restrict the number of workflows being executed at any time using a number of mechanisms | ||
|
||
## Controller level | ||
|
||
You can limit the total number of workflows that can execute at any one time in the [workflow controller ConfigMap](./workflow-controller-configmap.yaml). | ||
|
||
```yaml | ||
data: | ||
parallelism: "10" | ||
``` | ||
You can also limit the number of workflows that can execute in a single namespace. | ||
```yaml | ||
data: | ||
namespaceParallelism: "4" | ||
``` | ||
Workflows that are executing but restricted from running more nodes due to the other mechanisms on this page will still count towards the parallelism limits. | ||
## Workflow level | ||
You can restrict parallelism within a workflow using `parallelism` within a workflow or template. | ||
This only restricts total concurrent executions of steps or tasks within the same workflow. | ||
|
||
Examples | ||
|
||
1 [`parallelism-limit.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/parallelism-limit.yaml) restricts the parallelism of a [loop](./walk-through/loops.md) | ||
1 [`parallelism-nested.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/parallelism-nested.yaml) restricts the parallelism of a nested loop | ||
1 [`parallelism-nested-dag.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/parallelism-nested-dag.yaml) restricts the number of dag tasks that can be run at any one time | ||
1 [`parallelism-nested-workflow.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/parallelism-nested-workflow.yaml) shows how parallelism is inherited by children | ||
1 [`parallelism-template-limit.yaml`](https://github.com/argoproj/argo-workflows/blob/main/examples/parallelism-template-limit.yaml) shows how parallelism of looped templates is also restricted | ||
|
||
## Synchronization | ||
|
||
You can use [mutexes and semaphores](./synchronization.md) to control the parallel execution of sections of a workflow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.