-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
docs: Document node field selector. Closes #2860 #2882
Merged
+233
−93
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
27e4342
docs: Added docs for --node-field-selector. Closes #2860
markterm 833e0f2
Documented asynchronous job pattern
markterm 486ed59
Added new pages to README.md
markterm 2e1e4da
Fixed spelling mistake
markterm 5ea3438
Added documentation on retry with async jobs
markterm 033af04
Update docs/README.md
markterm 687b47e
Update docs/async-pattern.md
markterm c6e9e2f
Update docs/node-field-selector.md
markterm 3259f92
Update docs/README.md
markterm b90354d
Update docs/node-field-selector.md
markterm bac6fc3
Small twaeks
markterm 51dfce4
Changed --node-field-selector docs from GA to alpha
markterm ae8267b
Rebased on master
markterm a342f36
Fixed spacing issue
markterm File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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,96 @@ | ||
# Asynchronous Job Pattern | ||
|
||
## Introduction | ||
|
||
If triggering an external job (eg an Amazon EMR job) from Argo that does not run to completion in a container, there are two options: | ||
|
||
- create a container that polls the external job completion status | ||
- combine a trigger step that starts the job with a `Suspend` step that is unsuspended by an API call to Argo when the external job is complete. | ||
|
||
This document describes the second option in more detail. | ||
|
||
## The pattern | ||
|
||
The pattern involves two steps - the first step is a short-running step that triggers a long-running job outside Argo (eg an HTTP submission), and the second step is a `Suspend` step that suspends workflow exection and is ultimately either resumed or stopped (ie failed) via a call to the Argo API when the job outside Argo succeeds or fails. | ||
|
||
When implemented as a `WorkflowTemplate` it can look something like this: | ||
|
||
``` | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: WorkflowTemplate | ||
metadata: | ||
name: external-job-template | ||
spec: | ||
templates: | ||
- name: run-external-job | ||
inputs: | ||
parameters: | ||
- name: "job-cmd" | ||
steps: | ||
- - name: trigger-job | ||
template: trigger-job | ||
arguments: | ||
parameters: | ||
- name: "job-cmd" | ||
value: "{{inputs.parameters.job-cmd}}" | ||
- - name: wait-completion | ||
template: wait-completion | ||
arguments: | ||
parameters: | ||
- name: uuid | ||
value: "{{steps.trigger-job.outputs.result}}" | ||
|
||
- name: trigger-job | ||
inputs: | ||
parameters: | ||
- name: "job-cmd" | ||
value: "{{inputs.parameters.job-cmd}}" | ||
image: appropriate/curl:latest | ||
command: ["/bin/sh", "-c"] | ||
args: ["{{inputs.parameters.cmd}}"] | ||
|
||
- name: wait-completion | ||
inputs: | ||
parameters: | ||
- name: uuid | ||
suspend: {} | ||
``` | ||
|
||
In this case the ```job-cmd``` parameter can be a command that makes an http call via curl to an endpoint that returns a job uuid. More sophisticated submission and parsing of submission output could be done with something like a Python script step. | ||
|
||
On job completion the external job would need to call either resume if successful: | ||
|
||
``` | ||
curl --request PUT \ | ||
--url http://localhost:2746/api/v1/workflows/<NAMESPACE>/<WORKFLOWNAME>/resume | ||
--header 'content-type: application/json' \ | ||
--data '{ | ||
"namespace": "<NAMESPACE>", | ||
"name": "<WORKFLOWNAME>", | ||
"nodeFieldSelector": "inputs.parameters.uuid.value=<UUID>" | ||
}' | ||
``` | ||
|
||
or stop if unsuccessful: | ||
|
||
``` | ||
curl --request PUT \ | ||
--url http://localhost:2746/api/v1/workflows/<NAMESPACE>/<WORKFLOWNAME>/stop | ||
--header 'content-type: application/json' \ | ||
--data '{ | ||
"namespace": "<NAMESPACE>", | ||
"name": "<WORKFLOWNAME>", | ||
"nodeFieldSelector": "inputs.parameters.uuid.value=<UUID>", | ||
"message": "<FAILURE-MESSAGE>" | ||
}' | ||
``` | ||
|
||
## Retrying failed jobs | ||
|
||
Using `argo retry` on failed jobs that follow this pattern will cause Argo to re-attempt the Suspend step without re-triggering the job. | ||
|
||
Instead you need to use the `--restart-successful` option, eg if using the template from above: | ||
|
||
``` | ||
argo retry <WORKFLOWNAME> --restart-successful --node-field-selector templateRef.template=run-external-job,phase=Failed | ||
``` |
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,42 @@ | ||
# Node Field Selectors | ||
|
||
![alpha](assets/alpha.svg) | ||
|
||
> v2.8 and after | ||
|
||
## Introduction | ||
|
||
The resume, stop and retry Argo CLI and API commands support a `--node-field-selector` parameter to allow the user to select a subset of nodes for the command to apply to. | ||
|
||
In the case of the resume and stop commands these are the nodes that should be resumed or stopped. | ||
|
||
In the case of the retry command it allows specifying nodes that should be restarted even if they were previously successful (and must be used in combination with `--restart-successful`) | ||
|
||
The format of this when used with the CLI is: | ||
|
||
```--node-field-selector=FIELD=VALUE``` | ||
|
||
## Possible options | ||
|
||
The field can be any of: | ||
|
||
| Field | Description| | ||
|----------|------------| | ||
| displayName | Display name of the node | | ||
| templateName | Template name of the node | | ||
| phase | Phase status of the node - eg Running | | ||
| templateRef.name | The name of the WorkflowTemplate the node is referring to | | ||
| templateRef.template | The template within the WorkflowTemplate the node is referring to | | ||
| inputs.parameters.<NAME>.value | The value of input parameter NAME | | ||
|
||
The operator can be '=' or '!='. Multiple selectors can be combined with a comma, in which case they are ANDed together. | ||
|
||
## Examples | ||
|
||
To filter for nodes where the input parameter 'foo' is equal to 'bar': | ||
|
||
```--node-field-selector=inputs.parameters.foo.value=bar``` | ||
|
||
To filter for nodes where the input parameter 'foo' is equal to 'bar' and phase is not running: | ||
|
||
```--node-field-selector=foo1=bar1,phase!=Running``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doc is great