@@ -444,6 +444,10 @@ kubectl get -o yaml job job-backoff-limit-per-index-example
444
444
type : Failed
445
445
` ` `
446
446
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
+
447
451
Additionally, you may want to use the per-index backoff along with a
448
452
[pod failure policy](#pod-failure-policy). When using
449
453
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
553
557
to `podReplacementPolicy : Failed`. For more information, see [Pod replacement policy](#pod-replacement-policy).
554
558
{{< /note >}}
555
559
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
+
556
565
# # Success policy {#success-policy}
557
566
558
567
{{< feature-state feature_gate_name="JobSuccessPolicy" >}}
@@ -659,6 +668,45 @@ there is no automatic Job restart once the Job status is `type: Failed`.
659
668
That is, the Job termination mechanisms activated with `.spec.activeDeadlineSeconds`
660
669
and `.spec.backoffLimit` result in a permanent Job failure that requires manual intervention to resolve.
661
670
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
+
662
710
# # Clean up finished jobs automatically
663
711
664
712
Finished Jobs are usually no longer needed in the system. Keeping them around in
@@ -1063,6 +1111,13 @@ status:
1063
1111
terminating : 3 # three Pods are terminating and have not yet reached the Failed phase
1064
1112
` ` `
1065
1113
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
+
1066
1121
# ## Delegation of managing a Job object to external controller
1067
1122
1068
1123
{{< feature-state feature_gate_name="JobManagedBy" >}}
@@ -1107,6 +1162,13 @@ after the operation: the built-in Job controller and the external controller
1107
1162
indicated by the field value.
1108
1163
{{< /warning >}}
1109
1164
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
+
1110
1172
# # Alternatives
1111
1173
1112
1174
# ## Bare Pods
0 commit comments