JobPodFailurePolicy to GA

# Conflicts:
#	pkg/controller/job/job_controller_test.go
This commit is contained in:
Michal Wozniak 2024-07-12 17:21:32 +02:00
parent bae59799e9
commit f1233ac5e0
12 changed files with 56 additions and 298 deletions

View File

@ -4771,7 +4771,7 @@
},
"podFailurePolicy": {
"$ref": "#/definitions/io.k8s.api.batch.v1.PodFailurePolicy",
"description": "Specifies the policy of handling failed pods. In particular, it allows to specify the set of actions and conditions which need to be satisfied to take the associated action. If empty, the default behaviour applies - the counter of failed pods, represented by the jobs's .status.failed field, is incremented and it is checked against the backoffLimit. This field cannot be used in combination with restartPolicy=OnFailure.\n\nThis field is beta-level. It can be used when the `JobPodFailurePolicy` feature gate is enabled (enabled by default)."
"description": "Specifies the policy of handling failed pods. In particular, it allows to specify the set of actions and conditions which need to be satisfied to take the associated action. If empty, the default behaviour applies - the counter of failed pods, represented by the jobs's .status.failed field, is incremented and it is checked against the backoffLimit. This field cannot be used in combination with restartPolicy=OnFailure."
},
"podReplacementPolicy": {
"description": "podReplacementPolicy specifies when to create replacement Pods. Possible values are: - TerminatingOrFailed means that we recreate pods\n when they are terminating (has a metadata.deletionTimestamp) or failed.\n- Failed means to wait until a previously created Pod is fully terminated (has phase\n Failed or Succeeded) before creating a replacement Pod.\n\nWhen using podFailurePolicy, Failed is the the only allowed value. TerminatingOrFailed and Failed are allowed values when podFailurePolicy is not in use. This is an beta field. To use this, enable the JobPodReplacementPolicy feature toggle. This is on by default.",

View File

@ -368,7 +368,7 @@
"$ref": "#/components/schemas/io.k8s.api.batch.v1.PodFailurePolicy"
}
],
"description": "Specifies the policy of handling failed pods. In particular, it allows to specify the set of actions and conditions which need to be satisfied to take the associated action. If empty, the default behaviour applies - the counter of failed pods, represented by the jobs's .status.failed field, is incremented and it is checked against the backoffLimit. This field cannot be used in combination with restartPolicy=OnFailure.\n\nThis field is beta-level. It can be used when the `JobPodFailurePolicy` feature gate is enabled (enabled by default)."
"description": "Specifies the policy of handling failed pods. In particular, it allows to specify the set of actions and conditions which need to be satisfied to take the associated action. If empty, the default behaviour applies - the counter of failed pods, represented by the jobs's .status.failed field, is incremented and it is checked against the backoffLimit. This field cannot be used in combination with restartPolicy=OnFailure."
},
"podReplacementPolicy": {
"description": "podReplacementPolicy specifies when to create replacement Pods. Possible values are: - TerminatingOrFailed means that we recreate pods\n when they are terminating (has a metadata.deletionTimestamp) or failed.\n- Failed means to wait until a previously created Pod is fully terminated (has phase\n Failed or Succeeded) before creating a replacement Pod.\n\nWhen using podFailurePolicy, Failed is the the only allowed value. TerminatingOrFailed and Failed are allowed values when podFailurePolicy is not in use. This is an beta field. To use this, enable the JobPodReplacementPolicy feature toggle. This is on by default.",

View File

@ -330,8 +330,6 @@ type JobSpec struct {
// checked against the backoffLimit. This field cannot be used in combination
// with .spec.podTemplate.spec.restartPolicy=OnFailure.
//
// This field is beta-level. It can be used when the `JobPodFailurePolicy`
// feature gate is enabled (enabled by default).
// +optional
PodFailurePolicy *PodFailurePolicy

View File

@ -230,10 +230,9 @@ func TestCalculateSucceededIndexes(t *testing.T) {
func TestIsIndexFailed(t *testing.T) {
logger, _ := ktesting.NewTestContext(t)
cases := map[string]struct {
enableJobPodFailurePolicy bool
job batch.Job
pod *v1.Pod
wantResult bool
job batch.Job
pod *v1.Pod
wantResult bool
}{
"failed pod exceeding backoffLimitPerIndex, when backoffLimitPerIndex=0": {
job: batch.Job{
@ -255,8 +254,7 @@ func TestIsIndexFailed(t *testing.T) {
pod: buildPod().indexFailureCount("1").phase(v1.PodFailed).index("1").trackingFinalizer().Pod,
wantResult: true,
},
"matching FailIndex pod failure policy; JobPodFailurePolicy enabled": {
enableJobPodFailurePolicy: true,
"matching FailIndex pod failure policy": {
job: batch.Job{
Spec: batch.JobSpec{
Completions: ptr.To[int32](2),
@ -288,44 +286,10 @@ func TestIsIndexFailed(t *testing.T) {
}).index("0").trackingFinalizer().Pod,
wantResult: true,
},
"matching FailIndex pod failure policy; JobPodFailurePolicy disabled": {
enableJobPodFailurePolicy: false,
job: batch.Job{
Spec: batch.JobSpec{
Completions: ptr.To[int32](2),
BackoffLimitPerIndex: ptr.To[int32](1),
PodFailurePolicy: &batch.PodFailurePolicy{
Rules: []batch.PodFailurePolicyRule{
{
Action: batch.PodFailurePolicyActionFailIndex,
OnExitCodes: &batch.PodFailurePolicyOnExitCodesRequirement{
Operator: batch.PodFailurePolicyOnExitCodesOpIn,
Values: []int32{3},
},
},
},
},
},
},
pod: buildPod().indexFailureCount("0").status(v1.PodStatus{
Phase: v1.PodFailed,
ContainerStatuses: []v1.ContainerStatus{
{
State: v1.ContainerState{
Terminated: &v1.ContainerStateTerminated{
ExitCode: 3,
},
},
},
},
}).index("0").trackingFinalizer().Pod,
wantResult: false,
},
}
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobBackoffLimitPerIndex, true)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.enableJobPodFailurePolicy)
gotResult := isIndexFailed(logger, &tc.job, tc.pod)
if diff := cmp.Diff(tc.wantResult, gotResult); diff != "" {
t.Errorf("Unexpected result (-want,+got):\n%s", diff)
@ -337,11 +301,10 @@ func TestIsIndexFailed(t *testing.T) {
func TestCalculateFailedIndexes(t *testing.T) {
logger, _ := ktesting.NewTestContext(t)
cases := map[string]struct {
enableJobPodFailurePolicy bool
job batch.Job
pods []*v1.Pod
wantPrevFailedIndexes orderedIntervals
wantFailedIndexes orderedIntervals
job batch.Job
pods []*v1.Pod
wantPrevFailedIndexes orderedIntervals
wantFailedIndexes orderedIntervals
}{
"one new index failed": {
job: batch.Job{
@ -440,7 +403,6 @@ func TestGetPodsWithDelayedDeletionPerIndex(t *testing.T) {
logger, _ := ktesting.NewTestContext(t)
now := time.Now()
cases := map[string]struct {
enableJobPodFailurePolicy bool
job batch.Job
pods []*v1.Pod
expectedRmFinalizers sets.Set[string]
@ -581,7 +543,6 @@ func TestGetPodsWithDelayedDeletionPerIndex(t *testing.T) {
func TestGetNewIndexFailureCountValue(t *testing.T) {
logger, _ := ktesting.NewTestContext(t)
cases := map[string]struct {
enableJobPodFailurePolicy bool
job batch.Job
pod *v1.Pod
wantNewIndexFailureCount int32
@ -601,8 +562,7 @@ func TestGetNewIndexFailureCountValue(t *testing.T) {
pod: buildPod().uid("a").indexFailureCount("3").phase(v1.PodFailed).index("0").trackingFinalizer().Pod,
wantNewIndexFailureCount: 4,
},
"failed pod being replaced, matching the ignore rule; JobPodFailurePolicy enabled": {
enableJobPodFailurePolicy: true,
"failed pod being replaced, matching the ignore rule": {
job: batch.Job{
Spec: batch.JobSpec{
PodFailurePolicy: &batch.PodFailurePolicy{
@ -636,7 +596,6 @@ func TestGetNewIndexFailureCountValue(t *testing.T) {
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobBackoffLimitPerIndex, true)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.enableJobPodFailurePolicy)
gotNewIndexFailureCount, gotNewIndexIgnoredFailureCount := getNewIndexFailureCounts(logger, &tc.job, tc.pod)
if diff := cmp.Diff(tc.wantNewIndexFailureCount, gotNewIndexFailureCount); diff != "" {
t.Errorf("Unexpected set of pods with delayed deletion (-want,+got):\n%s", diff)

View File

@ -290,7 +290,6 @@ func TestControllerSyncJob(t *testing.T) {
// features
podIndexLabelDisabled bool
jobPodReplacementPolicy bool
jobPodFailurePolicy bool
jobSuccessPolicy bool
jobManagedBy bool
}{
@ -415,7 +414,6 @@ func TestControllerSyncJob(t *testing.T) {
activePods: 2,
failedPods: 0,
terminatingPods: 4,
jobPodFailurePolicy: true,
podFailurePolicy: &batch.PodFailurePolicy{},
expectedTerminating: nil,
expectedReady: ptr.To[int32](0),
@ -1158,11 +1156,10 @@ func TestControllerSyncJob(t *testing.T) {
expectedReady: ptr.To[int32](0),
},
"FailureTarget=False condition added manually is ignored": {
jobPodFailurePolicy: true,
parallelism: 1,
completions: 1,
activePods: 1,
readyPods: 1,
parallelism: 1,
completions: 1,
activePods: 1,
readyPods: 1,
initialStatus: &jobInitialStatus{
active: 1,
startTime: func() *time.Time {
@ -1254,7 +1251,6 @@ func TestControllerSyncJob(t *testing.T) {
logger, _ := ktesting.NewTestContext(t)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.PodIndexLabel, !tc.podIndexLabelDisabled)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodReplacementPolicy, tc.jobPodReplacementPolicy)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.jobPodFailurePolicy)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobSuccessPolicy, tc.jobSuccessPolicy)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobManagedBy, tc.jobManagedBy)
// job manager setup
@ -1279,9 +1275,7 @@ func TestControllerSyncJob(t *testing.T) {
if tc.jobPodReplacementPolicy {
job.Spec.PodReplacementPolicy = tc.podReplacementPolicy
}
if tc.jobPodFailurePolicy {
job.Spec.PodFailurePolicy = tc.podFailurePolicy
}
job.Spec.PodFailurePolicy = tc.podFailurePolicy
if tc.initialStatus != nil {
startTime := metav1.Now()
job.Status.StartTime = &startTime
@ -3092,7 +3086,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
}
testCases := map[string]struct {
enableJobPodFailurePolicy bool
enableJobPodReplacementPolicy bool
job batch.Job
pods []v1.Pod
@ -3103,7 +3096,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusTerminating *int32
}{
"default handling for pod failure if the container matching the exit codes does not match the containerName restriction": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3167,7 +3159,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusFailed: 1,
},
"running pod should not result in job fail based on OnExitCodes": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3205,7 +3196,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"fail job based on OnExitCodes": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3256,7 +3246,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"job marked already as failure target with failed pod": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3317,7 +3306,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"job marked already as failure target with failed pod, message based on already deleted pod": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3377,47 +3365,7 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusFailed: 1,
wantStatusSucceeded: 0,
},
"default handling for a failed pod when the feature is disabled even, despite matching rule": {
enableJobPodFailurePolicy: false,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
Spec: batch.JobSpec{
Selector: validSelector,
Template: validTemplate,
Parallelism: ptr.To[int32](1),
Completions: ptr.To[int32](1),
BackoffLimit: ptr.To[int32](6),
PodFailurePolicy: &batch.PodFailurePolicy{
Rules: onExitCodeRules,
},
},
},
pods: []v1.Pod{
{
Status: v1.PodStatus{
Phase: v1.PodFailed,
ContainerStatuses: []v1.ContainerStatus{
{
Name: "main-container",
State: v1.ContainerState{
Terminated: &v1.ContainerStateTerminated{
ExitCode: 5,
FinishedAt: testFinishedAt,
},
},
},
},
},
},
},
wantConditions: nil,
wantStatusActive: 1,
wantStatusFailed: 1,
wantStatusSucceeded: 0,
},
"fail job with multiple pods": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3473,7 +3421,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"fail indexed job based on OnExitCodes": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3525,7 +3472,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"fail job based on OnExitCodes with NotIn operator": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3584,7 +3530,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"default handling job based on OnExitCodes with NotIn operator": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3631,7 +3576,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"fail job based on OnExitCodes for InitContainer": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3692,7 +3636,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"ignore pod failure; both rules are matching, the first is executed only": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3738,7 +3681,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"ignore pod failure based on OnExitCodes": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3775,7 +3717,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"default job based on OnExitCodes": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3819,7 +3760,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"count pod failure based on OnExitCodes; both rules are matching, the first is executed only": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3872,7 +3812,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"count pod failure based on OnPodConditions; both rules are matching, the first is executed only": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3938,7 +3877,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"ignore pod failure based on OnPodConditions": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -3982,7 +3920,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"ignore pod failure based on OnPodConditions, ignored failures delays pod recreation": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -4029,7 +3966,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"fail job based on OnPodConditions": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -4086,7 +4022,6 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
wantStatusSucceeded: 0,
},
"terminating Pod not considered failed when JobPodFailurePolicy is enabled and used": {
enableJobPodFailurePolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
ObjectMeta: validObjectMeta,
@ -4115,16 +4050,12 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
DeletionTimestamp: &now,
},
Status: v1.PodStatus{
Phase: v1.PodRunning,
},
},
},
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.enableJobPodFailurePolicy)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodReplacementPolicy, tc.enableJobPodReplacementPolicy)
if tc.job.Spec.PodReplacementPolicy == nil {
@ -4206,7 +4137,6 @@ func TestSyncJobWithJobSuccessPolicy(t *testing.T) {
}
testCases := map[string]struct {
enableJobFailurePolicy bool
enableBackoffLimitPerIndex bool
enableJobSuccessPolicy bool
enableJobPodReplacementPolicy bool
@ -4308,7 +4238,6 @@ func TestSyncJobWithJobSuccessPolicy(t *testing.T) {
},
"job with podFailurePolicy and successPolicy; jobPodReplacementPolicy feature enabled; job has SuccessCriteriaMet condition if job meets to successPolicy and doesn't meet to podFailurePolicy": {
enableJobSuccessPolicy: true,
enableJobFailurePolicy: true,
enableJobPodReplacementPolicy: true,
job: batch.Job{
TypeMeta: validTypeMeta,
@ -4360,7 +4289,6 @@ func TestSyncJobWithJobSuccessPolicy(t *testing.T) {
},
"job with podFailurePolicy and successPolicy; jobPodReplacementPolicy feature disabled; job has SuccessCriteriaMet condition if job meets to successPolicy and doesn't meet to podFailurePolicy": {
enableJobSuccessPolicy: true,
enableJobFailurePolicy: true,
enableJobPodReplacementPolicy: false,
job: batch.Job{
TypeMeta: validTypeMeta,
@ -4631,7 +4559,6 @@ func TestSyncJobWithJobSuccessPolicy(t *testing.T) {
},
"job with successPolicy and podFailurePolicy; jobPodReplacementPolicy feature enabled; job has a failed condition when job meets to both successPolicy and podFailurePolicy": {
enableJobSuccessPolicy: true,
enableJobFailurePolicy: true,
enableJobPodReplacementPolicy: true,
job: batch.Job{
TypeMeta: validTypeMeta,
@ -4787,7 +4714,6 @@ func TestSyncJobWithJobSuccessPolicy(t *testing.T) {
},
"job with successPolicy and podFailurePolicy; jobPodReplacementPolicy feature enabled; job with SuccessCriteriaMet has never been transitioned to FailureTarget and Failed even if job meets podFailurePolicy": {
enableJobSuccessPolicy: true,
enableJobFailurePolicy: true,
enableJobPodReplacementPolicy: true,
job: batch.Job{
TypeMeta: validTypeMeta,
@ -4990,7 +4916,6 @@ func TestSyncJobWithJobSuccessPolicy(t *testing.T) {
},
"job with successPolicy and podFailureTarget; jobPodReplacementPolicy feature enabled; job with FailureTarget has never been transitioned to SuccessCriteriaMet even if job meets successPolicy": {
enableJobSuccessPolicy: true,
enableJobFailurePolicy: true,
enableJobPodReplacementPolicy: true,
job: batch.Job{
TypeMeta: validTypeMeta,
@ -5100,7 +5025,6 @@ func TestSyncJobWithJobSuccessPolicy(t *testing.T) {
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.enableJobFailurePolicy)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobBackoffLimitPerIndex, tc.enableBackoffLimitPerIndex)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobSuccessPolicy, tc.enableJobSuccessPolicy)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodReplacementPolicy, tc.enableJobPodReplacementPolicy)
@ -5172,7 +5096,6 @@ func TestSyncJobWithJobBackoffLimitPerIndex(t *testing.T) {
testCases := map[string]struct {
enableJobBackoffLimitPerIndex bool
enableJobPodFailurePolicy bool
enableJobPodReplacementPolicy bool
enableJobManagedBy bool
job batch.Job
@ -5302,7 +5225,6 @@ func TestSyncJobWithJobBackoffLimitPerIndex(t *testing.T) {
},
"single failed index due to FailIndex action, the job continues": {
enableJobBackoffLimitPerIndex: true,
enableJobPodFailurePolicy: true,
enableJobPodReplacementPolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
@ -5352,7 +5274,6 @@ func TestSyncJobWithJobBackoffLimitPerIndex(t *testing.T) {
},
"job failed index due to FailJob action": {
enableJobBackoffLimitPerIndex: true,
enableJobPodFailurePolicy: true,
enableJobPodReplacementPolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
@ -5417,7 +5338,6 @@ func TestSyncJobWithJobBackoffLimitPerIndex(t *testing.T) {
},
"job pod failure ignored due to matching Ignore action": {
enableJobBackoffLimitPerIndex: true,
enableJobPodFailurePolicy: true,
enableJobPodReplacementPolicy: true,
job: batch.Job{
TypeMeta: metav1.TypeMeta{Kind: "Job"},
@ -5780,7 +5700,6 @@ func TestSyncJobWithJobBackoffLimitPerIndex(t *testing.T) {
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobBackoffLimitPerIndex, tc.enableJobBackoffLimitPerIndex)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.enableJobPodFailurePolicy)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodReplacementPolicy, tc.enableJobPodReplacementPolicy)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobManagedBy, tc.enableJobManagedBy)
clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})

View File

@ -336,6 +336,7 @@ const (
// kep: https://kep.k8s.io/3329
// alpha: v1.25
// beta: v1.26
// stable: v1.31
//
// Allow users to specify handling of pod failures based on container exit codes
// and pod conditions.
@ -1061,7 +1062,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
JobManagedBy: {Default: false, PreRelease: featuregate.Alpha},
JobPodFailurePolicy: {Default: true, PreRelease: featuregate.Beta},
JobPodFailurePolicy: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.33
JobPodReplacementPolicy: {Default: true, PreRelease: featuregate.Beta},

View File

@ -17097,7 +17097,7 @@ func schema_k8sio_api_batch_v1_JobSpec(ref common.ReferenceCallback) common.Open
},
"podFailurePolicy": {
SchemaProps: spec.SchemaProps{
Description: "Specifies the policy of handling failed pods. In particular, it allows to specify the set of actions and conditions which need to be satisfied to take the associated action. If empty, the default behaviour applies - the counter of failed pods, represented by the jobs's .status.failed field, is incremented and it is checked against the backoffLimit. This field cannot be used in combination with restartPolicy=OnFailure.\n\nThis field is beta-level. It can be used when the `JobPodFailurePolicy` feature gate is enabled (enabled by default).",
Description: "Specifies the policy of handling failed pods. In particular, it allows to specify the set of actions and conditions which need to be satisfied to take the associated action. If empty, the default behaviour applies - the counter of failed pods, represented by the jobs's .status.failed field, is incremented and it is checked against the backoffLimit. This field cannot be used in combination with restartPolicy=OnFailure.",
Ref: ref("k8s.io/api/batch/v1.PodFailurePolicy"),
},
},

View File

@ -88,7 +88,6 @@ func TestJobStrategy_PrepareForUpdate(t *testing.T) {
}
cases := map[string]struct {
enableJobPodFailurePolicy bool
enableJobBackoffLimitPerIndex bool
enableJobPodReplacementPolicy bool
enableJobSuccessPolicy bool
@ -264,8 +263,7 @@ func TestJobStrategy_PrepareForUpdate(t *testing.T) {
},
},
},
"update job with a new field; updated when JobPodFailurePolicy enabled": {
enableJobPodFailurePolicy: true,
"update job with a new field; updated": {
job: batch.Job{
ObjectMeta: getValidObjectMeta(0),
Spec: batch.JobSpec{
@ -345,62 +343,7 @@ func TestJobStrategy_PrepareForUpdate(t *testing.T) {
},
},
},
"update job with a new field; not updated when JobPodFailurePolicy disabled": {
enableJobPodFailurePolicy: false,
job: batch.Job{
ObjectMeta: getValidObjectMeta(0),
Spec: batch.JobSpec{
Selector: validSelector,
Template: validPodTemplateSpec,
PodFailurePolicy: nil,
},
},
updatedJob: batch.Job{
ObjectMeta: getValidObjectMeta(0),
Spec: batch.JobSpec{
Selector: validSelector,
Template: validPodTemplateSpec,
PodFailurePolicy: updatedPodFailurePolicy,
},
},
wantJob: batch.Job{
ObjectMeta: getValidObjectMeta(0),
Spec: batch.JobSpec{
Selector: validSelector,
Template: validPodTemplateSpec,
PodFailurePolicy: nil,
},
},
},
"update pre-existing field; updated when JobPodFailurePolicy enabled": {
enableJobPodFailurePolicy: true,
job: batch.Job{
ObjectMeta: getValidObjectMeta(0),
Spec: batch.JobSpec{
Selector: validSelector,
Template: validPodTemplateSpec,
PodFailurePolicy: podFailurePolicy,
},
},
updatedJob: batch.Job{
ObjectMeta: getValidObjectMeta(0),
Spec: batch.JobSpec{
Selector: validSelector,
Template: validPodTemplateSpec,
PodFailurePolicy: updatedPodFailurePolicy,
},
},
wantJob: batch.Job{
ObjectMeta: getValidObjectMeta(1),
Spec: batch.JobSpec{
Selector: validSelector,
Template: validPodTemplateSpec,
PodFailurePolicy: updatedPodFailurePolicy,
},
},
},
"update pre-existing field; updated when JobPodFailurePolicy disabled": {
enableJobPodFailurePolicy: false,
"update pre-existing field; updated": {
job: batch.Job{
ObjectMeta: getValidObjectMeta(0),
Spec: batch.JobSpec{
@ -569,7 +512,6 @@ func TestJobStrategy_PrepareForUpdate(t *testing.T) {
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.enableJobPodFailurePolicy)
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobBackoffLimitPerIndex, tc.enableJobBackoffLimitPerIndex)
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobPodReplacementPolicy, tc.enableJobPodReplacementPolicy)
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobSuccessPolicy, tc.enableJobSuccessPolicy)
@ -613,7 +555,6 @@ func TestJobStrategy_PrepareForCreate(t *testing.T) {
}
cases := map[string]struct {
enableJobPodFailurePolicy bool
enableJobBackoffLimitPerIndex bool
enableJobPodReplacementPolicy bool
enableJobManageBy bool
@ -727,8 +668,7 @@ func TestJobStrategy_PrepareForCreate(t *testing.T) {
},
},
},
"create job with a new field; JobPodFailurePolicy enabled": {
enableJobPodFailurePolicy: true,
"create job with a new field": {
job: batch.Job{
ObjectMeta: getValidObjectMeta(0),
Spec: batch.JobSpec{
@ -790,27 +730,6 @@ func TestJobStrategy_PrepareForCreate(t *testing.T) {
},
},
},
"create job with a new field; JobPodFailurePolicy disabled": {
enableJobPodFailurePolicy: false,
job: batch.Job{
ObjectMeta: getValidObjectMeta(0),
Spec: batch.JobSpec{
Selector: validSelector,
ManualSelector: ptr.To(false),
Template: validPodTemplateSpec,
PodFailurePolicy: podFailurePolicy,
},
},
wantJob: batch.Job{
ObjectMeta: getValidObjectMeta(1),
Spec: batch.JobSpec{
Selector: validSelector,
ManualSelector: ptr.To(false),
Template: expectedPodTemplateSpec,
PodFailurePolicy: nil,
},
},
},
"job does not allow setting status on create": {
job: batch.Job{
ObjectMeta: getValidObjectMeta(0),
@ -832,9 +751,8 @@ func TestJobStrategy_PrepareForCreate(t *testing.T) {
},
},
},
"create job with pod failure policy using FailIndex action; JobPodFailurePolicy enabled, JobBackoffLimitPerIndex disabled": {
"create job with pod failure policy using FailIndex action; JobBackoffLimitPerIndex disabled": {
enableJobBackoffLimitPerIndex: false,
enableJobPodFailurePolicy: true,
job: batch.Job{
ObjectMeta: getValidObjectMeta(0),
Spec: batch.JobSpec{
@ -867,9 +785,8 @@ func TestJobStrategy_PrepareForCreate(t *testing.T) {
},
},
},
"create job with multiple pod failure policy rules, some using FailIndex action; JobPodFailurePolicy enabled, JobBackoffLimitPerIndex disabled": {
"create job with multiple pod failure policy rules, some using FailIndex action; JobBackoffLimitPerIndex disabled": {
enableJobBackoffLimitPerIndex: false,
enableJobPodFailurePolicy: true,
job: batch.Job{
ObjectMeta: getValidObjectMeta(0),
Spec: batch.JobSpec{
@ -976,7 +893,6 @@ func TestJobStrategy_PrepareForCreate(t *testing.T) {
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.enableJobPodFailurePolicy)
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobBackoffLimitPerIndex, tc.enableJobBackoffLimitPerIndex)
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobPodReplacementPolicy, tc.enableJobPodReplacementPolicy)
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobManagedBy, tc.enableJobManageBy)
@ -1027,7 +943,6 @@ func TestJobStrategy_ValidateUpdate(t *testing.T) {
validPodTemplateSpecNever.Spec.RestartPolicy = api.RestartPolicyNever
now := metav1.Now()
cases := map[string]struct {
enableJobPodFailurePolicy bool
enableJobBackoffLimitPerIndex bool
job *batch.Job
update func(*batch.Job)
@ -1258,7 +1173,6 @@ func TestJobStrategy_ValidateUpdate(t *testing.T) {
},
},
"old job is using FailIndex JobBackoffLimitPerIndex is disabled, but FailIndex was already used": {
enableJobPodFailurePolicy: true,
enableJobBackoffLimitPerIndex: false,
job: &batch.Job{
ObjectMeta: metav1.ObjectMeta{
@ -1294,7 +1208,6 @@ func TestJobStrategy_ValidateUpdate(t *testing.T) {
}
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.enableJobPodFailurePolicy)
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobBackoffLimitPerIndex, tc.enableJobBackoffLimitPerIndex)
newJob := tc.job.DeepCopy()
tc.update(newJob)
@ -1541,7 +1454,6 @@ func TestJobStrategy_Validate(t *testing.T) {
validPodSpecNever := podtest.MakePodSpec(podtest.SetRestartPolicy(api.RestartPolicyNever))
validObjectMeta := getValidObjectMeta(0)
testcases := map[string]struct {
enableJobPodFailurePolicy bool
enableJobBackoffLimitPerIndex bool
job *batch.Job
wantJob *batch.Job
@ -1743,7 +1655,6 @@ func TestJobStrategy_Validate(t *testing.T) {
wantWarningCount: 1,
},
"FailIndex action; when JobBackoffLimitPerIndex is disabled - validation error": {
enableJobPodFailurePolicy: true,
enableJobBackoffLimitPerIndex: false,
job: &batch.Job{
ObjectMeta: validObjectMeta,
@ -1796,7 +1707,6 @@ func TestJobStrategy_Validate(t *testing.T) {
wantWarningCount: 1,
},
"FailIndex action; when JobBackoffLimitPerIndex is enabled, but not used - validation error": {
enableJobPodFailurePolicy: true,
enableJobBackoffLimitPerIndex: true,
job: &batch.Job{
ObjectMeta: validObjectMeta,
@ -1849,7 +1759,6 @@ func TestJobStrategy_Validate(t *testing.T) {
wantWarningCount: 1,
},
"FailIndex action; when JobBackoffLimitPerIndex is enabled and used - no error": {
enableJobPodFailurePolicy: true,
enableJobBackoffLimitPerIndex: true,
job: &batch.Job{
ObjectMeta: validObjectMeta,
@ -1909,7 +1818,6 @@ func TestJobStrategy_Validate(t *testing.T) {
}
for name, tc := range testcases {
t.Run(name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.enableJobPodFailurePolicy)
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.JobBackoffLimitPerIndex, tc.enableJobBackoffLimitPerIndex)
errs := Strategy.Validate(ctx, tc.job)
if len(errs) != int(tc.wantWarningCount) {

View File

@ -213,8 +213,6 @@ message JobSpec {
// checked against the backoffLimit. This field cannot be used in combination
// with restartPolicy=OnFailure.
//
// This field is beta-level. It can be used when the `JobPodFailurePolicy`
// feature gate is enabled (enabled by default).
// +optional
optional PodFailurePolicy podFailurePolicy = 11;

View File

@ -338,8 +338,6 @@ type JobSpec struct {
// checked against the backoffLimit. This field cannot be used in combination
// with restartPolicy=OnFailure.
//
// This field is beta-level. It can be used when the `JobPodFailurePolicy`
// feature gate is enabled (enabled by default).
// +optional
PodFailurePolicy *PodFailurePolicy `json:"podFailurePolicy,omitempty" protobuf:"bytes,11,opt,name=podFailurePolicy"`
@ -636,7 +634,6 @@ const (
// JobReasonPodFailurePolicy reason indicates a job failure condition is added due to
// a failed pod matching a pod failure policy rule
// https://kep.k8s.io/3329
// This is currently a beta field.
JobReasonPodFailurePolicy string = "PodFailurePolicy"
// JobReasonBackOffLimitExceeded reason indicates that pods within a job have failed a number of
// times higher than backOffLimit times.

View File

@ -115,7 +115,7 @@ var map_JobSpec = map[string]string{
"parallelism": "Specifies the maximum desired number of pods the job should run at any given time. The actual number of pods running in steady state will be less than this number when ((.spec.completions - .status.successful) < .spec.parallelism), i.e. when the work left to do is less than max parallelism. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/",
"completions": "Specifies the desired number of successfully finished pods the job should be run with. Setting to null means that the success of any pod signals the success of all pods, and allows parallelism to have any positive value. Setting to 1 means that parallelism is limited to 1 and the success of that pod signals the success of the job. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/",
"activeDeadlineSeconds": "Specifies the duration in seconds relative to the startTime that the job may be continuously active before the system tries to terminate it; value must be positive integer. If a Job is suspended (at creation or through an update), this timer will effectively be stopped and reset when the Job is resumed again.",
"podFailurePolicy": "Specifies the policy of handling failed pods. In particular, it allows to specify the set of actions and conditions which need to be satisfied to take the associated action. If empty, the default behaviour applies - the counter of failed pods, represented by the jobs's .status.failed field, is incremented and it is checked against the backoffLimit. This field cannot be used in combination with restartPolicy=OnFailure.\n\nThis field is beta-level. It can be used when the `JobPodFailurePolicy` feature gate is enabled (enabled by default).",
"podFailurePolicy": "Specifies the policy of handling failed pods. In particular, it allows to specify the set of actions and conditions which need to be satisfied to take the associated action. If empty, the default behaviour applies - the counter of failed pods, represented by the jobs's .status.failed field, is incremented and it is checked against the backoffLimit. This field cannot be used in combination with restartPolicy=OnFailure.",
"successPolicy": "successPolicy specifies the policy when the Job can be declared as succeeded. If empty, the default behavior applies - the Job is declared as succeeded only when the number of succeeded pods equals to the completions. When the field is specified, it must be immutable and works only for the Indexed Jobs. Once the Job meets the SuccessPolicy, the lingering pods are terminated.\n\nThis field is alpha-level. To use this field, you must enable the `JobSuccessPolicy` feature gate (disabled by default).",
"backoffLimit": "Specifies the number of retries before marking this job failed. Defaults to 6",
"backoffLimitPerIndex": "Specifies the limit for the number of retries within an index before marking this index as failed. When enabled the number of failures per index is kept in the pod's batch.kubernetes.io/job-index-failure-count annotation. It can only be set when Job's completionMode=Indexed, and the Pod's restart policy is Never. The field is immutable. This field is beta-level. It can be used when the `JobBackoffLimitPerIndex` feature gate is enabled (enabled by default).",

View File

@ -161,7 +161,6 @@ func TestJobPodFailurePolicyWithFailedPodDeletedDuringControllerRestart(t *testi
},
},
}
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, true)
closeFn, restConfig, cs, ns := setup(t, "simple")
defer closeFn()
@ -343,7 +342,6 @@ func TestJobPodFailurePolicy(t *testing.T) {
},
}
testCases := map[string]struct {
enableJobPodFailurePolicy bool
restartController bool
job batchv1.Job
podStatus v1.PodStatus
@ -353,13 +351,12 @@ func TestJobPodFailurePolicy(t *testing.T) {
wantJobFinishedMetric metricLabelsWithValue
wantPodFailuresHandledByPolicyRuleMetric *metricLabelsWithValue
}{
"pod status matching the configured FailJob rule on exit codes; job terminated when JobPodFailurePolicy enabled": {
enableJobPodFailurePolicy: true,
job: job,
podStatus: podStatusMatchingOnExitCodesTerminateRule,
wantActive: 0,
wantFailed: 1,
wantJobConditionType: batchv1.JobFailed,
"pod status matching the configured FailJob rule on exit codes; job terminated": {
job: job,
podStatus: podStatusMatchingOnExitCodesTerminateRule,
wantActive: 0,
wantFailed: 1,
wantJobConditionType: batchv1.JobFailed,
wantJobFinishedMetric: metricLabelsWithValue{
Labels: []string{"NonIndexed", "failed", "PodFailurePolicy"},
Value: 1,
@ -369,38 +366,24 @@ func TestJobPodFailurePolicy(t *testing.T) {
Value: 1,
},
},
"pod status matching the configured FailJob rule on exit codes; with controller restart; job terminated when JobPodFailurePolicy enabled": {
enableJobPodFailurePolicy: true,
restartController: true,
job: job,
podStatus: podStatusMatchingOnExitCodesTerminateRule,
wantActive: 0,
wantFailed: 1,
wantJobConditionType: batchv1.JobFailed,
"pod status matching the configured FailJob rule on exit codes; with controller restart; job terminated": {
restartController: true,
job: job,
podStatus: podStatusMatchingOnExitCodesTerminateRule,
wantActive: 0,
wantFailed: 1,
wantJobConditionType: batchv1.JobFailed,
wantJobFinishedMetric: metricLabelsWithValue{
Labels: []string{"NonIndexed", "failed", "PodFailurePolicy"},
Value: 1,
},
},
"pod status matching the configured FailJob rule on exit codes; default handling when JobPodFailurePolicy disabled": {
enableJobPodFailurePolicy: false,
job: job,
podStatus: podStatusMatchingOnExitCodesTerminateRule,
wantActive: 1,
wantFailed: 1,
wantJobConditionType: batchv1.JobComplete,
wantJobFinishedMetric: metricLabelsWithValue{
Labels: []string{"NonIndexed", "succeeded", ""},
Value: 1,
},
},
"pod status matching the configured Ignore rule on pod conditions; pod failure not counted when JobPodFailurePolicy enabled": {
enableJobPodFailurePolicy: true,
job: job,
podStatus: podStatusMatchingOnPodConditionsIgnoreRule,
wantActive: 1,
wantFailed: 0,
wantJobConditionType: batchv1.JobComplete,
"pod status matching the configured Ignore rule on pod conditions; pod failure not counted": {
job: job,
podStatus: podStatusMatchingOnPodConditionsIgnoreRule,
wantActive: 1,
wantFailed: 0,
wantJobConditionType: batchv1.JobComplete,
wantPodFailuresHandledByPolicyRuleMetric: &metricLabelsWithValue{
Labels: []string{"Ignore"},
Value: 1,
@ -410,13 +393,12 @@ func TestJobPodFailurePolicy(t *testing.T) {
Value: 1,
},
},
"pod status matching the configured Count rule on exit codes; pod failure counted when JobPodFailurePolicy enabled": {
enableJobPodFailurePolicy: true,
job: job,
podStatus: podStatusMatchingOnExitCodesCountRule,
wantActive: 1,
wantFailed: 1,
wantJobConditionType: batchv1.JobComplete,
"pod status matching the configured Count rule on exit codes; pod failure counted": {
job: job,
podStatus: podStatusMatchingOnExitCodesCountRule,
wantActive: 1,
wantFailed: 1,
wantJobConditionType: batchv1.JobComplete,
wantJobFinishedMetric: metricLabelsWithValue{
Labels: []string{"NonIndexed", "succeeded", ""},
Value: 1,
@ -426,13 +408,12 @@ func TestJobPodFailurePolicy(t *testing.T) {
Value: 1,
},
},
"pod status non-matching any configured rule; pod failure counted when JobPodFailurePolicy enabled": {
enableJobPodFailurePolicy: true,
job: job,
podStatus: podStatusNotMatchingAnyRule,
wantActive: 1,
wantFailed: 1,
wantJobConditionType: batchv1.JobComplete,
"pod status non-matching any configured rule; pod failure counted": {
job: job,
podStatus: podStatusNotMatchingAnyRule,
wantActive: 1,
wantFailed: 1,
wantJobConditionType: batchv1.JobComplete,
wantJobFinishedMetric: metricLabelsWithValue{
Labels: []string{"NonIndexed", "succeeded", ""},
Value: 1,
@ -446,7 +427,6 @@ func TestJobPodFailurePolicy(t *testing.T) {
for name, test := range testCases {
t.Run(name, func(t *testing.T) {
resetMetrics()
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, test.enableJobPodFailurePolicy)
closeFn, restConfig, clientSet, ns := setup(t, "simple")
defer closeFn()
@ -1802,7 +1782,6 @@ func TestBackoffLimitPerIndex(t *testing.T) {
for name, test := range testCases {
t.Run(name, func(t *testing.T) {
resetMetrics()
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, true)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobBackoffLimitPerIndex, true)
closeFn, restConfig, clientSet, ns := setup(t, "simple")
@ -2913,7 +2892,6 @@ func TestJobPodReplacementPolicy(t *testing.T) {
tc := tc
t.Run(name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodReplacementPolicy, tc.podReplacementPolicyEnabled)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.jobSpec.PodFailurePolicy != nil)
closeFn, restConfig, clientSet, ns := setup(t, "pod-replacement-policy")
t.Cleanup(closeFn)