Skip to content

Commit 67fe8ed

Browse files
committed
Update the docs for JobManagedBy and JobPodReplacementPolicy related to pod termination
1 parent 8b08791 commit 67fe8ed

File tree

1 file changed

+62
-0
lines changed
  • content/en/docs/concepts/workloads/controllers

1 file changed

+62
-0
lines changed

content/en/docs/concepts/workloads/controllers/job.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,10 @@ kubectl get -o yaml job job-backoff-limit-per-index-example
444444
type: Failed
445445
```
446446
447+
Note that, since v1.31, you will also observe in the status the `FailureTarget`
448+
Job condition, with the same `reason` and `message` as for the the `Failed`
449+
condition (see also [Job termination and cleanup](#job-termination-and-cleanup)).
450+
447451
Additionally, you may want to use the per-index backoff along with a
448452
[pod failure policy](#pod-failure-policy). When using
449453
per-index backoff, there is a new `FailIndex` action available which allows you to
@@ -553,6 +557,11 @@ terminating Pods only once these Pods reach the terminal `Failed` phase. This be
553557
to `podReplacementPolicy: Failed`. For more information, see [Pod replacement policy](#pod-replacement-policy).
554558
{{< /note >}}
555559

560+
When you use the `podFailurePolicy`, and the Job fails due to the pod
561+
matching the rule with the `FailJob` action, then the Job controller triggers
562+
the Job termination process by adding the `FailureTarget` condition.
563+
See [Job termination and cleanup](#job-termination-and-cleanup) for more details.
564+
556565
## Success policy {#success-policy}
557566

558567
{{< feature-state feature_gate_name="JobSuccessPolicy" >}}
@@ -659,6 +668,45 @@ there is no automatic Job restart once the Job status is `type: Failed`.
659668
That is, the Job termination mechanisms activated with `.spec.activeDeadlineSeconds`
660669
and `.spec.backoffLimit` result in a permanent Job failure that requires manual intervention to resolve.
661670

671+
### Terminal Job conditions
672+
673+
A Job has two possible terminal states, it ends up either succeeded, or failed,
674+
and these states are reflected by the presence of the Job conditions `Complete`
675+
or `Failed`, respectively.
676+
677+
The failure scenarios encompass:
678+
- the `.spec.backoffLimit`
679+
- the `.spec.activeDeadlineSeconds` is exceeded
680+
- the `.spec.backoffLimitPerIndex` is exceeded (see [Backoff limit per index](#backoff-limit-per-index))
681+
- the Pod matches the Job Pod Failure Policy rule with the `FailJob` action (see more [Pod failure policy](#pod-failure-policy))
682+
683+
The success scenarios encompass:
684+
- the `.spec.completions` is reached
685+
- the criteria specified by the Job Success Policy are met (see more [Success policy](#success-policy))
686+
687+
### Termination of Job pods
688+
689+
Prior to v1.31 the Job terminal conditions are added when the Job termination
690+
process is triggered, and all Pod finalizers are removed, but some pods may
691+
still remain running at that point in time.
692+
693+
Since v1.31, when you enable either the `JobManagedBy` or
694+
`JobPodReplacementPolicy` (enabled by default)
695+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/), the
696+
Job controller awaits for termination of all pods before adding a condition
697+
indicating that the Job is finished (either `Complete` or `Failed`).
698+
699+
Note that, the process of terminating all pods may take a substantial amount
700+
of time, depending on a Pod's `terminationGracePeriodSeconds` (see
701+
[Pod termination](#docs/concepts/workloads/pods/pod-lifecycle/#pod-termination)),
702+
and thus adding the terminal Job condition, even if the fate of the Job is
703+
already determined.
704+
705+
If you want to know the fate of the Job as soon as determined you can use,
706+
since v1.31, the `FailureTarget` and `SuccessCriteriaMet` conditions, which
707+
cover all scenarios in which Job controller triggers the Job termination process
708+
(see [Terminal Job conditions](#terminal-job-conditions)).
709+
662710
## Clean up finished jobs automatically
663711

664712
Finished Jobs are usually no longer needed in the system. Keeping them around in
@@ -1063,6 +1111,13 @@ status:
10631111
terminating: 3 # three Pods are terminating and have not yet reached the Failed phase
10641112
```
10651113
1114+
{{< note >}}
1115+
Since v1.31, when you enable the `JobPodReplacementPolicy`
1116+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
1117+
(enabled by default), the Job controller awaits for termination of all pods
1118+
before marking a Job as terminal (see [Termination of Job Pods](#termination-of-job-pods)).
1119+
{{< /note >}}
1120+
10661121
### Delegation of managing a Job object to external controller
10671122

10681123
{{< feature-state feature_gate_name="JobManagedBy" >}}
@@ -1107,6 +1162,13 @@ after the operation: the built-in Job controller and the external controller
11071162
indicated by the field value.
11081163
{{< /warning >}}
11091164

1165+
{{< note >}}
1166+
Since v1.31, when you enable the `JobManagedBy`
1167+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/),
1168+
the Job controller awaits for termination of all pods before marking a Job as
1169+
terminal (see [Termination of Job Pods](#termination-of-job-pods)).
1170+
{{< /note >}}
1171+
11101172
## Alternatives
11111173

11121174
### Bare Pods

0 commit comments

Comments
 (0)