Skip to content

Commit de00a3c

Browse files
authored
Merge pull request kubernetes#125442 from mimowo/job-pod-failure-policy-stable
Graduate JobPodFailurePolicy to stable
2 parents c7dab2a + f1233ac commit de00a3c

File tree

12 files changed

+56
-298
lines changed

12 files changed

+56
-298
lines changed

api/openapi-spec/swagger.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/openapi-spec/v3/apis__batch__v1_openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@
368368
"$ref": "#/components/schemas/io.k8s.api.batch.v1.PodFailurePolicy"
369369
}
370370
],
371-
"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)."
371+
"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."
372372
},
373373
"podReplacementPolicy": {
374374
"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.",

pkg/apis/batch/types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,6 @@ type JobSpec struct {
330330
// checked against the backoffLimit. This field cannot be used in combination
331331
// with .spec.podTemplate.spec.restartPolicy=OnFailure.
332332
//
333-
// This field is beta-level. It can be used when the `JobPodFailurePolicy`
334-
// feature gate is enabled (enabled by default).
335333
// +optional
336334
PodFailurePolicy *PodFailurePolicy
337335

pkg/controller/job/indexed_job_utils_test.go

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,9 @@ func TestCalculateSucceededIndexes(t *testing.T) {
230230
func TestIsIndexFailed(t *testing.T) {
231231
logger, _ := ktesting.NewTestContext(t)
232232
cases := map[string]struct {
233-
enableJobPodFailurePolicy bool
234-
job batch.Job
235-
pod *v1.Pod
236-
wantResult bool
233+
job batch.Job
234+
pod *v1.Pod
235+
wantResult bool
237236
}{
238237
"failed pod exceeding backoffLimitPerIndex, when backoffLimitPerIndex=0": {
239238
job: batch.Job{
@@ -255,8 +254,7 @@ func TestIsIndexFailed(t *testing.T) {
255254
pod: buildPod().indexFailureCount("1").phase(v1.PodFailed).index("1").trackingFinalizer().Pod,
256255
wantResult: true,
257256
},
258-
"matching FailIndex pod failure policy; JobPodFailurePolicy enabled": {
259-
enableJobPodFailurePolicy: true,
257+
"matching FailIndex pod failure policy": {
260258
job: batch.Job{
261259
Spec: batch.JobSpec{
262260
Completions: ptr.To[int32](2),
@@ -288,44 +286,10 @@ func TestIsIndexFailed(t *testing.T) {
288286
}).index("0").trackingFinalizer().Pod,
289287
wantResult: true,
290288
},
291-
"matching FailIndex pod failure policy; JobPodFailurePolicy disabled": {
292-
enableJobPodFailurePolicy: false,
293-
job: batch.Job{
294-
Spec: batch.JobSpec{
295-
Completions: ptr.To[int32](2),
296-
BackoffLimitPerIndex: ptr.To[int32](1),
297-
PodFailurePolicy: &batch.PodFailurePolicy{
298-
Rules: []batch.PodFailurePolicyRule{
299-
{
300-
Action: batch.PodFailurePolicyActionFailIndex,
301-
OnExitCodes: &batch.PodFailurePolicyOnExitCodesRequirement{
302-
Operator: batch.PodFailurePolicyOnExitCodesOpIn,
303-
Values: []int32{3},
304-
},
305-
},
306-
},
307-
},
308-
},
309-
},
310-
pod: buildPod().indexFailureCount("0").status(v1.PodStatus{
311-
Phase: v1.PodFailed,
312-
ContainerStatuses: []v1.ContainerStatus{
313-
{
314-
State: v1.ContainerState{
315-
Terminated: &v1.ContainerStateTerminated{
316-
ExitCode: 3,
317-
},
318-
},
319-
},
320-
},
321-
}).index("0").trackingFinalizer().Pod,
322-
wantResult: false,
323-
},
324289
}
325290
for name, tc := range cases {
326291
t.Run(name, func(t *testing.T) {
327292
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobBackoffLimitPerIndex, true)
328-
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.enableJobPodFailurePolicy)
329293
gotResult := isIndexFailed(logger, &tc.job, tc.pod)
330294
if diff := cmp.Diff(tc.wantResult, gotResult); diff != "" {
331295
t.Errorf("Unexpected result (-want,+got):\n%s", diff)
@@ -337,11 +301,10 @@ func TestIsIndexFailed(t *testing.T) {
337301
func TestCalculateFailedIndexes(t *testing.T) {
338302
logger, _ := ktesting.NewTestContext(t)
339303
cases := map[string]struct {
340-
enableJobPodFailurePolicy bool
341-
job batch.Job
342-
pods []*v1.Pod
343-
wantPrevFailedIndexes orderedIntervals
344-
wantFailedIndexes orderedIntervals
304+
job batch.Job
305+
pods []*v1.Pod
306+
wantPrevFailedIndexes orderedIntervals
307+
wantFailedIndexes orderedIntervals
345308
}{
346309
"one new index failed": {
347310
job: batch.Job{
@@ -440,7 +403,6 @@ func TestGetPodsWithDelayedDeletionPerIndex(t *testing.T) {
440403
logger, _ := ktesting.NewTestContext(t)
441404
now := time.Now()
442405
cases := map[string]struct {
443-
enableJobPodFailurePolicy bool
444406
job batch.Job
445407
pods []*v1.Pod
446408
expectedRmFinalizers sets.Set[string]
@@ -581,7 +543,6 @@ func TestGetPodsWithDelayedDeletionPerIndex(t *testing.T) {
581543
func TestGetNewIndexFailureCountValue(t *testing.T) {
582544
logger, _ := ktesting.NewTestContext(t)
583545
cases := map[string]struct {
584-
enableJobPodFailurePolicy bool
585546
job batch.Job
586547
pod *v1.Pod
587548
wantNewIndexFailureCount int32
@@ -601,8 +562,7 @@ func TestGetNewIndexFailureCountValue(t *testing.T) {
601562
pod: buildPod().uid("a").indexFailureCount("3").phase(v1.PodFailed).index("0").trackingFinalizer().Pod,
602563
wantNewIndexFailureCount: 4,
603564
},
604-
"failed pod being replaced, matching the ignore rule; JobPodFailurePolicy enabled": {
605-
enableJobPodFailurePolicy: true,
565+
"failed pod being replaced, matching the ignore rule": {
606566
job: batch.Job{
607567
Spec: batch.JobSpec{
608568
PodFailurePolicy: &batch.PodFailurePolicy{
@@ -636,7 +596,6 @@ func TestGetNewIndexFailureCountValue(t *testing.T) {
636596
for name, tc := range cases {
637597
t.Run(name, func(t *testing.T) {
638598
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobBackoffLimitPerIndex, true)
639-
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.enableJobPodFailurePolicy)
640599
gotNewIndexFailureCount, gotNewIndexIgnoredFailureCount := getNewIndexFailureCounts(logger, &tc.job, tc.pod)
641600
if diff := cmp.Diff(tc.wantNewIndexFailureCount, gotNewIndexFailureCount); diff != "" {
642601
t.Errorf("Unexpected set of pods with delayed deletion (-want,+got):\n%s", diff)

0 commit comments

Comments
 (0)