Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45135 from tenzen-y/job-success-policy-doc
Add JobSuccessPolicy Doc
- Loading branch information
Showing
3 changed files
with
95 additions
and
0 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
14 changes: 14 additions & 0 deletions
14
...docs/reference/command-line-tools-reference/feature-gates/job-success-policy.md
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,14 @@ | ||
--- | ||
title: JobSuccessPolicy | ||
content_type: feature_gate | ||
|
||
_build: | ||
list: never | ||
render: false | ||
|
||
stages: | ||
- stage: alpha | ||
defaultValue: false | ||
fromVersion: "1.30" | ||
--- | ||
Allow users to specify when a Job can be declared as succeeded based on the set of succeeded pods. |
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,25 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
spec: | ||
parallelism: 10 | ||
completions: 10 | ||
completionMode: Indexed # Required for the success policy | ||
successPolicy: | ||
rules: | ||
- succeededIndexes: 0,2-3 | ||
succeededCount: 1 | ||
template: | ||
spec: | ||
containers: | ||
- name: main | ||
image: python | ||
command: # Provided that at least one of the Pods with 0, 2, and 3 indexes has succeeded, | ||
# the overall Job is a success. | ||
- python3 | ||
- -c | ||
- | | ||
import os, sys | ||
if os.environ.get("JOB_COMPLETION_INDEX") == "2": | ||
sys.exit(0) | ||
else: | ||
sys.exit(1) |