diff --git a/pkg/apis/batch/fuzzer/fuzzer.go b/pkg/apis/batch/fuzzer/fuzzer.go index 154d9f6bfc5..d7bfd37dc29 100644 --- a/pkg/apis/batch/fuzzer/fuzzer.go +++ b/pkg/apis/batch/fuzzer/fuzzer.go @@ -47,11 +47,11 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { } else { j.ManualSelector = nil } - if c.Rand.Int31()%2 == 0 { - j.CompletionMode = batch.NonIndexedCompletion - } else { - j.CompletionMode = batch.IndexedCompletion + mode := batch.NonIndexedCompletion + if c.RandBool() { + mode = batch.IndexedCompletion } + j.CompletionMode = &mode // We're fuzzing the internal JobSpec type, not the v1 type, so we don't // need to fuzz the nil value. j.Suspend = pointer.BoolPtr(c.RandBool()) diff --git a/pkg/apis/batch/types.go b/pkg/apis/batch/types.go index b4c76b1bf79..29a49f9e0d3 100644 --- a/pkg/apis/batch/types.go +++ b/pkg/apis/batch/types.go @@ -189,7 +189,7 @@ type JobSpec struct { // If the Job controller observes a mode that it doesn't recognize, the // controller skips updates for the Job. // +optional - CompletionMode CompletionMode + CompletionMode *CompletionMode // Suspend specifies whether the Job controller should create Pods or not. If // a Job is created with suspend set to true, no Pods are created by the Job diff --git a/pkg/apis/batch/v1/defaults.go b/pkg/apis/batch/v1/defaults.go index 9638950e91b..14a4c1aeeff 100644 --- a/pkg/apis/batch/v1/defaults.go +++ b/pkg/apis/batch/v1/defaults.go @@ -19,6 +19,8 @@ package v1 import ( batchv1 "k8s.io/api/batch/v1" "k8s.io/apimachinery/pkg/runtime" + utilfeature "k8s.io/apiserver/pkg/util/feature" + "k8s.io/kubernetes/pkg/features" utilpointer "k8s.io/utils/pointer" ) @@ -43,10 +45,11 @@ func SetDefaults_Job(obj *batchv1.Job) { if labels != nil && len(obj.Labels) == 0 { obj.Labels = labels } - if len(obj.Spec.CompletionMode) == 0 { - obj.Spec.CompletionMode = batchv1.NonIndexedCompletion + if utilfeature.DefaultFeatureGate.Enabled(features.IndexedJob) && obj.Spec.CompletionMode == nil { + mode := batchv1.NonIndexedCompletion + obj.Spec.CompletionMode = &mode } - if obj.Spec.Suspend == nil { + if utilfeature.DefaultFeatureGate.Enabled(features.SuspendJob) && obj.Spec.Suspend == nil { obj.Spec.Suspend = utilpointer.BoolPtr(false) } } diff --git a/pkg/apis/batch/v1/defaults_test.go b/pkg/apis/batch/v1/defaults_test.go index 6e1cd173341..6fccc0be1a8 100644 --- a/pkg/apis/batch/v1/defaults_test.go +++ b/pkg/apis/batch/v1/defaults_test.go @@ -25,9 +25,12 @@ import ( "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apiserver/pkg/util/feature" + featuregatetesting "k8s.io/component-base/featuregate/testing" "k8s.io/kubernetes/pkg/api/legacyscheme" _ "k8s.io/kubernetes/pkg/apis/batch/install" _ "k8s.io/kubernetes/pkg/apis/core/install" + "k8s.io/kubernetes/pkg/features" "k8s.io/utils/pointer" . "k8s.io/kubernetes/pkg/apis/batch/v1" @@ -36,9 +39,11 @@ import ( func TestSetDefaultJob(t *testing.T) { defaultLabels := map[string]string{"default": "default"} tests := map[string]struct { - original *batchv1.Job - expected *batchv1.Job - expectLabels bool + indexedJobEnabled bool + suspendJobEnabled bool + original *batchv1.Job + expected *batchv1.Job + expectLabels bool }{ "All unspecified -> sets all to default values": { original: &batchv1.Job{ @@ -50,19 +55,17 @@ func TestSetDefaultJob(t *testing.T) { }, expected: &batchv1.Job{ Spec: batchv1.JobSpec{ - Completions: pointer.Int32Ptr(1), - Parallelism: pointer.Int32Ptr(1), - BackoffLimit: pointer.Int32Ptr(6), - CompletionMode: batchv1.NonIndexedCompletion, - Suspend: pointer.BoolPtr(false), + Completions: pointer.Int32Ptr(1), + Parallelism: pointer.Int32Ptr(1), + BackoffLimit: pointer.Int32Ptr(6), }, }, expectLabels: true, }, - "suspend set, everything else is defaulted": { + "All unspecified, indexed job enabled -> sets all to default values": { + indexedJobEnabled: true, original: &batchv1.Job{ Spec: batchv1.JobSpec{ - Suspend: pointer.BoolPtr(true), Template: v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, }, @@ -73,13 +76,51 @@ func TestSetDefaultJob(t *testing.T) { Completions: pointer.Int32Ptr(1), Parallelism: pointer.Int32Ptr(1), BackoffLimit: pointer.Int32Ptr(6), - CompletionMode: batchv1.NonIndexedCompletion, - Suspend: pointer.BoolPtr(true), + CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), }, }, expectLabels: true, }, - "All unspecified -> all pointers, CompletionMode are defaulted and no default labels": { + "All unspecified, suspend job enabled -> sets all to default values": { + suspendJobEnabled: true, + original: &batchv1.Job{ + Spec: batchv1.JobSpec{ + Template: v1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, + }, + }, + }, + expected: &batchv1.Job{ + Spec: batchv1.JobSpec{ + Completions: pointer.Int32Ptr(1), + Parallelism: pointer.Int32Ptr(1), + BackoffLimit: pointer.Int32Ptr(6), + Suspend: pointer.BoolPtr(false), + }, + }, + expectLabels: true, + }, + "suspend set, everything else is defaulted": { + suspendJobEnabled: true, + original: &batchv1.Job{ + Spec: batchv1.JobSpec{ + Suspend: pointer.BoolPtr(true), + Template: v1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, + }, + }, + }, + expected: &batchv1.Job{ + Spec: batchv1.JobSpec{ + Completions: pointer.Int32Ptr(1), + Parallelism: pointer.Int32Ptr(1), + BackoffLimit: pointer.Int32Ptr(6), + Suspend: pointer.BoolPtr(true), + }, + }, + expectLabels: true, + }, + "All unspecified -> all pointers are defaulted and no default labels": { original: &batchv1.Job{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{"mylabel": "myvalue"}, @@ -92,11 +133,9 @@ func TestSetDefaultJob(t *testing.T) { }, expected: &batchv1.Job{ Spec: batchv1.JobSpec{ - Completions: pointer.Int32Ptr(1), - Parallelism: pointer.Int32Ptr(1), - BackoffLimit: pointer.Int32Ptr(6), - CompletionMode: batchv1.NonIndexedCompletion, - Suspend: pointer.BoolPtr(false), + Completions: pointer.Int32Ptr(1), + Parallelism: pointer.Int32Ptr(1), + BackoffLimit: pointer.Int32Ptr(6), }, }, }, @@ -111,10 +150,8 @@ func TestSetDefaultJob(t *testing.T) { }, expected: &batchv1.Job{ Spec: batchv1.JobSpec{ - Parallelism: pointer.Int32Ptr(0), - BackoffLimit: pointer.Int32Ptr(6), - CompletionMode: batchv1.NonIndexedCompletion, - Suspend: pointer.BoolPtr(false), + Parallelism: pointer.Int32Ptr(0), + BackoffLimit: pointer.Int32Ptr(6), }, }, expectLabels: true, @@ -130,10 +167,8 @@ func TestSetDefaultJob(t *testing.T) { }, expected: &batchv1.Job{ Spec: batchv1.JobSpec{ - Parallelism: pointer.Int32Ptr(2), - BackoffLimit: pointer.Int32Ptr(6), - CompletionMode: batchv1.NonIndexedCompletion, - Suspend: pointer.BoolPtr(false), + Parallelism: pointer.Int32Ptr(2), + BackoffLimit: pointer.Int32Ptr(6), }, }, expectLabels: true, @@ -149,11 +184,9 @@ func TestSetDefaultJob(t *testing.T) { }, expected: &batchv1.Job{ Spec: batchv1.JobSpec{ - Completions: pointer.Int32Ptr(2), - Parallelism: pointer.Int32Ptr(1), - BackoffLimit: pointer.Int32Ptr(6), - CompletionMode: batchv1.NonIndexedCompletion, - Suspend: pointer.BoolPtr(false), + Completions: pointer.Int32Ptr(2), + Parallelism: pointer.Int32Ptr(1), + BackoffLimit: pointer.Int32Ptr(6), }, }, expectLabels: true, @@ -169,11 +202,9 @@ func TestSetDefaultJob(t *testing.T) { }, expected: &batchv1.Job{ Spec: batchv1.JobSpec{ - Completions: pointer.Int32Ptr(1), - Parallelism: pointer.Int32Ptr(1), - BackoffLimit: pointer.Int32Ptr(5), - CompletionMode: batchv1.NonIndexedCompletion, - Suspend: pointer.BoolPtr(false), + Completions: pointer.Int32Ptr(1), + Parallelism: pointer.Int32Ptr(1), + BackoffLimit: pointer.Int32Ptr(5), }, }, expectLabels: true, @@ -184,8 +215,8 @@ func TestSetDefaultJob(t *testing.T) { Completions: pointer.Int32Ptr(8), Parallelism: pointer.Int32Ptr(9), BackoffLimit: pointer.Int32Ptr(10), - CompletionMode: batchv1.NonIndexedCompletion, - Suspend: pointer.BoolPtr(true), + CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), + Suspend: pointer.BoolPtr(false), Template: v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, }, @@ -196,8 +227,8 @@ func TestSetDefaultJob(t *testing.T) { Completions: pointer.Int32Ptr(8), Parallelism: pointer.Int32Ptr(9), BackoffLimit: pointer.Int32Ptr(10), - CompletionMode: batchv1.NonIndexedCompletion, - Suspend: pointer.BoolPtr(true), + CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), + Suspend: pointer.BoolPtr(false), Template: v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, }, @@ -211,7 +242,7 @@ func TestSetDefaultJob(t *testing.T) { Completions: pointer.Int32Ptr(11), Parallelism: pointer.Int32Ptr(10), BackoffLimit: pointer.Int32Ptr(9), - CompletionMode: batchv1.IndexedCompletion, + CompletionMode: completionModePtr(batchv1.IndexedCompletion), Suspend: pointer.BoolPtr(true), Template: v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, @@ -223,7 +254,7 @@ func TestSetDefaultJob(t *testing.T) { Completions: pointer.Int32Ptr(11), Parallelism: pointer.Int32Ptr(10), BackoffLimit: pointer.Int32Ptr(9), - CompletionMode: batchv1.IndexedCompletion, + CompletionMode: completionModePtr(batchv1.IndexedCompletion), Suspend: pointer.BoolPtr(true), }, }, @@ -233,6 +264,8 @@ func TestSetDefaultJob(t *testing.T) { for name, test := range tests { t.Run(name, func(t *testing.T) { + defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.IndexedJob, test.indexedJobEnabled)() + defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.SuspendJob, test.suspendJobEnabled)() original := test.original expected := test.expected @@ -256,8 +289,8 @@ func TestSetDefaultJob(t *testing.T) { t.Errorf("Unexpected equality: %v", actual.Labels) } } - if actual.Spec.CompletionMode != expected.Spec.CompletionMode { - t.Errorf("Got CompletionMode: %v, want: %v", actual.Spec.CompletionMode, expected.Spec.CompletionMode) + if diff := cmp.Diff(expected.Spec.CompletionMode, actual.Spec.CompletionMode); diff != "" { + t.Errorf("Unexpected CompletionMode (-want,+got):\n%s", diff) } }) } @@ -304,7 +337,7 @@ func TestSetDefaultCronJob(t *testing.T) { expected: &batchv1.CronJob{ Spec: batchv1.CronJobSpec{ ConcurrencyPolicy: batchv1.AllowConcurrent, - Suspend: newBool(false), + Suspend: pointer.BoolPtr(false), SuccessfulJobsHistoryLimit: pointer.Int32Ptr(3), FailedJobsHistoryLimit: pointer.Int32Ptr(1), }, @@ -314,7 +347,7 @@ func TestSetDefaultCronJob(t *testing.T) { original: &batchv1.CronJob{ Spec: batchv1.CronJobSpec{ ConcurrencyPolicy: batchv1.ForbidConcurrent, - Suspend: newBool(true), + Suspend: pointer.BoolPtr(true), SuccessfulJobsHistoryLimit: pointer.Int32Ptr(5), FailedJobsHistoryLimit: pointer.Int32Ptr(5), }, @@ -322,7 +355,7 @@ func TestSetDefaultCronJob(t *testing.T) { expected: &batchv1.CronJob{ Spec: batchv1.CronJobSpec{ ConcurrencyPolicy: batchv1.ForbidConcurrent, - Suspend: newBool(true), + Suspend: pointer.BoolPtr(true), SuccessfulJobsHistoryLimit: pointer.Int32Ptr(5), FailedJobsHistoryLimit: pointer.Int32Ptr(5), }, @@ -354,8 +387,6 @@ func TestSetDefaultCronJob(t *testing.T) { } } -func newBool(val bool) *bool { - p := new(bool) - *p = val - return p +func completionModePtr(m batchv1.CompletionMode) *batchv1.CompletionMode { + return &m } diff --git a/pkg/apis/batch/v1/zz_generated.conversion.go b/pkg/apis/batch/v1/zz_generated.conversion.go index eae9cda5ec8..eb72b8b8087 100644 --- a/pkg/apis/batch/v1/zz_generated.conversion.go +++ b/pkg/apis/batch/v1/zz_generated.conversion.go @@ -392,7 +392,7 @@ func autoConvert_v1_JobSpec_To_batch_JobSpec(in *v1.JobSpec, out *batch.JobSpec, return err } out.TTLSecondsAfterFinished = (*int32)(unsafe.Pointer(in.TTLSecondsAfterFinished)) - out.CompletionMode = batch.CompletionMode(in.CompletionMode) + out.CompletionMode = (*batch.CompletionMode)(unsafe.Pointer(in.CompletionMode)) out.Suspend = (*bool)(unsafe.Pointer(in.Suspend)) return nil } @@ -408,7 +408,7 @@ func autoConvert_batch_JobSpec_To_v1_JobSpec(in *batch.JobSpec, out *v1.JobSpec, return err } out.TTLSecondsAfterFinished = (*int32)(unsafe.Pointer(in.TTLSecondsAfterFinished)) - out.CompletionMode = v1.CompletionMode(in.CompletionMode) + out.CompletionMode = (*v1.CompletionMode)(unsafe.Pointer(in.CompletionMode)) out.Suspend = (*bool)(unsafe.Pointer(in.Suspend)) return nil } diff --git a/pkg/apis/batch/validation/validation.go b/pkg/apis/batch/validation/validation.go index b0b534cc52e..34a498a96a2 100644 --- a/pkg/apis/batch/validation/validation.go +++ b/pkg/apis/batch/validation/validation.go @@ -129,12 +129,12 @@ func validateJobSpec(spec *batch.JobSpec, fldPath *field.Path, opts apivalidatio if spec.TTLSecondsAfterFinished != nil { allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(*spec.TTLSecondsAfterFinished), fldPath.Child("ttlSecondsAfterFinished"))...) } - // CompletionMode might be empty when IndexedJob feature gate is disabled. - if spec.CompletionMode != "" { - if spec.CompletionMode != batch.NonIndexedCompletion && spec.CompletionMode != batch.IndexedCompletion { + // CompletionMode might be nil when IndexedJob feature gate is disabled. + if spec.CompletionMode != nil { + if *spec.CompletionMode != batch.NonIndexedCompletion && *spec.CompletionMode != batch.IndexedCompletion { allErrs = append(allErrs, field.NotSupported(fldPath.Child("completionMode"), spec.CompletionMode, []string{string(batch.NonIndexedCompletion), string(batch.IndexedCompletion)})) } - if spec.CompletionMode == batch.IndexedCompletion { + if *spec.CompletionMode == batch.IndexedCompletion { if spec.Completions == nil { allErrs = append(allErrs, field.Required(fldPath.Child("completions"), fmt.Sprintf("when completion mode is %s", batch.IndexedCompletion))) } diff --git a/pkg/apis/batch/validation/validation_test.go b/pkg/apis/batch/validation/validation_test.go index 4d40ac85a3d..12dd1d960d6 100644 --- a/pkg/apis/batch/validation/validation_test.go +++ b/pkg/apis/batch/validation/validation_test.go @@ -86,7 +86,7 @@ func TestValidateJob(t *testing.T) { }, Spec: batch.JobSpec{ Selector: validManualSelector, - ManualSelector: newBool(true), + ManualSelector: pointer.BoolPtr(true), Template: validPodTemplateSpecForManual, }, }, @@ -110,7 +110,7 @@ func TestValidateJob(t *testing.T) { Spec: batch.JobSpec{ Selector: validGeneratedSelector, Template: validPodTemplateSpecForGenerated, - CompletionMode: batch.NonIndexedCompletion, + CompletionMode: completionModePtr(batch.NonIndexedCompletion), }, }, "valid Indexed completion mode": { @@ -122,7 +122,7 @@ func TestValidateJob(t *testing.T) { Spec: batch.JobSpec{ Selector: validGeneratedSelector, Template: validPodTemplateSpecForGenerated, - CompletionMode: batch.IndexedCompletion, + CompletionMode: completionModePtr(batch.IndexedCompletion), Completions: pointer.Int32Ptr(2), Parallelism: pointer.Int32Ptr(100000), }, @@ -192,7 +192,7 @@ func TestValidateJob(t *testing.T) { }, Spec: batch.JobSpec{ Selector: validManualSelector, - ManualSelector: newBool(true), + ManualSelector: pointer.BoolPtr(true), Template: api.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{"y": "z"}, @@ -213,7 +213,7 @@ func TestValidateJob(t *testing.T) { }, Spec: batch.JobSpec{ Selector: validManualSelector, - ManualSelector: newBool(true), + ManualSelector: pointer.BoolPtr(true), Template: api.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{"controller-uid": "4d5e6f"}, @@ -234,7 +234,7 @@ func TestValidateJob(t *testing.T) { }, Spec: batch.JobSpec{ Selector: validManualSelector, - ManualSelector: newBool(true), + ManualSelector: pointer.BoolPtr(true), Template: api.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: validManualSelector.MatchLabels, @@ -255,7 +255,7 @@ func TestValidateJob(t *testing.T) { }, Spec: batch.JobSpec{ Selector: validManualSelector, - ManualSelector: newBool(true), + ManualSelector: pointer.BoolPtr(true), Template: api.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: validManualSelector.MatchLabels, @@ -289,7 +289,7 @@ func TestValidateJob(t *testing.T) { Spec: batch.JobSpec{ Selector: validGeneratedSelector, Template: validPodTemplateSpecForGenerated, - CompletionMode: batch.IndexedCompletion, + CompletionMode: completionModePtr(batch.IndexedCompletion), }, }, "spec.parallelism: must be less than or equal to 100000 when completion mode is Indexed": { @@ -301,7 +301,7 @@ func TestValidateJob(t *testing.T) { Spec: batch.JobSpec{ Selector: validGeneratedSelector, Template: validPodTemplateSpecForGenerated, - CompletionMode: batch.IndexedCompletion, + CompletionMode: completionModePtr(batch.IndexedCompletion), Completions: pointer.Int32Ptr(2), Parallelism: pointer.Int32Ptr(100001), }, @@ -404,12 +404,12 @@ func TestValidateJobUpdate(t *testing.T) { Spec: batch.JobSpec{ Selector: validGeneratedSelector, Template: validPodTemplateSpecForGenerated, - CompletionMode: batch.IndexedCompletion, + CompletionMode: completionModePtr(batch.IndexedCompletion), Completions: pointer.Int32Ptr(2), }, }, update: func(job *batch.Job) { - job.Spec.CompletionMode = batch.NonIndexedCompletion + job.Spec.CompletionMode = completionModePtr(batch.NonIndexedCompletion) }, err: &field.Error{ Type: field.ErrorTypeInvalid, @@ -762,7 +762,7 @@ func TestValidateCronJob(t *testing.T) { ConcurrencyPolicy: batch.AllowConcurrent, JobTemplate: batch.JobTemplateSpec{ Spec: batch.JobSpec{ - ManualSelector: newBool(true), + ManualSelector: pointer.BoolPtr(true), Template: validPodTemplateSpec, }, }, @@ -865,8 +865,6 @@ func TestValidateCronJob(t *testing.T) { } } -func newBool(val bool) *bool { - p := new(bool) - *p = val - return p +func completionModePtr(m batch.CompletionMode) *batch.CompletionMode { + return &m } diff --git a/pkg/apis/batch/zz_generated.deepcopy.go b/pkg/apis/batch/zz_generated.deepcopy.go index b1e1f8e814c..4c414b2f611 100644 --- a/pkg/apis/batch/zz_generated.deepcopy.go +++ b/pkg/apis/batch/zz_generated.deepcopy.go @@ -271,6 +271,11 @@ func (in *JobSpec) DeepCopyInto(out *JobSpec) { *out = new(int32) **out = **in } + if in.CompletionMode != nil { + in, out := &in.CompletionMode, &out.CompletionMode + *out = new(CompletionMode) + **out = **in + } if in.Suspend != nil { in, out := &in.Suspend, &out.Suspend *out = new(bool) diff --git a/pkg/controller/job/indexed_job_utils.go b/pkg/controller/job/indexed_job_utils.go index d964f2b8d9c..9f9a09ac51b 100644 --- a/pkg/controller/job/indexed_job_utils.go +++ b/pkg/controller/job/indexed_job_utils.go @@ -34,6 +34,10 @@ const ( unknownCompletionIndex = -1 ) +func isIndexedJob(job *batch.Job) bool { + return job.Spec.CompletionMode != nil && *job.Spec.CompletionMode == batch.IndexedCompletion +} + // calculateSucceededIndexes returns a string representation of the list of // succeeded indexes in compressed format and the number of succeeded indexes. func calculateSucceededIndexes(pods []*v1.Pod) (string, int32) { diff --git a/pkg/controller/job/job_controller.go b/pkg/controller/job/job_controller.go index ba583de82a0..df45826f745 100644 --- a/pkg/controller/job/job_controller.go +++ b/pkg/controller/job/job_controller.go @@ -470,10 +470,14 @@ func (jm *Controller) syncJob(key string) (bool, error) { } // Cannot create Pods if this is an Indexed Job and the feature is disabled. - if !utilfeature.DefaultFeatureGate.Enabled(features.IndexedJob) && job.Spec.CompletionMode == batch.IndexedCompletion { + if !utilfeature.DefaultFeatureGate.Enabled(features.IndexedJob) && isIndexedJob(&job) { jm.recorder.Event(&job, v1.EventTypeWarning, "IndexedJobDisabled", "Skipped Indexed Job sync because feature is disabled.") return false, nil } + if job.Spec.CompletionMode != nil && *job.Spec.CompletionMode != batch.NonIndexedCompletion && *job.Spec.CompletionMode != batch.IndexedCompletion { + jm.recorder.Event(&job, v1.EventTypeWarning, "UnknownCompletionMode", "Skipped Job sync because completion mode is unknown") + return false, nil + } // Check the expectations of the job before counting active pods, otherwise a new pod can sneak in // and update the expectations after we've retrieved active pods from the store. If a new pod enters @@ -525,7 +529,7 @@ func (jm *Controller) syncJob(key string) (bool, error) { } var succeededIndexes string - if job.Spec.CompletionMode == batch.IndexedCompletion { + if isIndexedJob(&job) { succeededIndexes, succeeded = calculateSucceededIndexes(pods) } jobConditionsChanged := false @@ -625,7 +629,7 @@ func (jm *Controller) syncJob(key string) (bool, error) { job.Status.Active = active job.Status.Succeeded = succeeded job.Status.Failed = failed - if job.Spec.CompletionMode == batch.IndexedCompletion { + if isIndexedJob(&job) { job.Status.CompletedIndexes = succeededIndexes } @@ -807,14 +811,14 @@ func (jm *Controller) manageJob(job *batch.Job, activePods []*v1.Pod, succeeded wait := sync.WaitGroup{} var indexesToAdd []int - if job.Spec.Completions != nil && job.Spec.CompletionMode == batch.IndexedCompletion { + if job.Spec.Completions != nil && isIndexedJob(job) { indexesToAdd = firstPendingIndexes(allPods, int(diff), int(*job.Spec.Completions)) diff = int32(len(indexesToAdd)) } active += diff podTemplate := job.Spec.Template.DeepCopy() - if job.Spec.CompletionMode == batch.IndexedCompletion { + if isIndexedJob(job) { addCompletionIndexEnvVariables(podTemplate) } @@ -893,7 +897,7 @@ func (jm *Controller) manageJob(job *batch.Job, activePods []*v1.Pod, succeeded func activePodsForRemoval(job *batch.Job, pods []*v1.Pod, rmAtLeast int) []*v1.Pod { var rm, left []*v1.Pod - if job.Spec.CompletionMode == batch.IndexedCompletion { + if isIndexedJob(job) { rm = make([]*v1.Pod, 0, rmAtLeast) left = make([]*v1.Pod, 0, len(pods)-rmAtLeast) rm, left = appendDuplicatedIndexPodsForRemoval(rm, left, pods) @@ -950,7 +954,7 @@ func getBackoff(queue workqueue.RateLimitingInterface, key interface{}) time.Dur func countPodsByPhase(job *batch.Job, pods []*v1.Pod, phase v1.PodPhase) int { result := 0 for _, p := range pods { - if phase == p.Status.Phase && (job.Spec.CompletionMode != batch.IndexedCompletion || getCompletionIndex(p.Annotations) != unknownCompletionIndex) { + if phase == p.Status.Phase && (!isIndexedJob(job) || getCompletionIndex(p.Annotations) != unknownCompletionIndex) { result++ } } diff --git a/pkg/controller/job/job_controller_test.go b/pkg/controller/job/job_controller_test.go index 9d1c08d9b40..5e1e579874f 100644 --- a/pkg/controller/job/job_controller_test.go +++ b/pkg/controller/job/job_controller_test.go @@ -64,7 +64,6 @@ func newJob(parallelism, completions, backoffLimit int32, completionMode batch.C Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{"foo": "bar"}, }, - CompletionMode: completionMode, Template: v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ @@ -79,6 +78,9 @@ func newJob(parallelism, completions, backoffLimit int32, completionMode batch.C }, }, } + if completionMode != "" { + j.Spec.CompletionMode = &completionMode + } // Special case: -1 for either completions or parallelism means leave nil (negative is not allowed // in practice by validation. if completions >= 0 { diff --git a/pkg/registry/batch/job/strategy.go b/pkg/registry/batch/job/strategy.go index 212b0459b67..6aa8ec1548f 100644 --- a/pkg/registry/batch/job/strategy.go +++ b/pkg/registry/batch/job/strategy.go @@ -39,7 +39,6 @@ import ( "k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/apis/batch/validation" "k8s.io/kubernetes/pkg/features" - "k8s.io/utils/pointer" "sigs.k8s.io/structured-merge-diff/v4/fieldpath" ) @@ -95,11 +94,11 @@ func (jobStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { } if !utilfeature.DefaultFeatureGate.Enabled(features.IndexedJob) { - job.Spec.CompletionMode = batch.NonIndexedCompletion + job.Spec.CompletionMode = nil } if !utilfeature.DefaultFeatureGate.Enabled(features.SuspendJob) { - job.Spec.Suspend = pointer.BoolPtr(false) + job.Spec.Suspend = nil } pod.DropDisabledTemplateFields(&job.Spec.Template, nil) @@ -115,8 +114,8 @@ func (jobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object newJob.Spec.TTLSecondsAfterFinished = nil } - if !utilfeature.DefaultFeatureGate.Enabled(features.IndexedJob) && oldJob.Spec.CompletionMode == batch.NonIndexedCompletion { - newJob.Spec.CompletionMode = batch.NonIndexedCompletion + if !utilfeature.DefaultFeatureGate.Enabled(features.IndexedJob) && oldJob.Spec.CompletionMode == nil { + newJob.Spec.CompletionMode = nil } if !utilfeature.DefaultFeatureGate.Enabled(features.SuspendJob) { diff --git a/pkg/registry/batch/job/strategy_test.go b/pkg/registry/batch/job/strategy_test.go index a9da0f196b2..00f0082015d 100644 --- a/pkg/registry/batch/job/strategy_test.go +++ b/pkg/registry/batch/job/strategy_test.go @@ -99,7 +99,7 @@ func testJobStrategy(t *testing.T) { // Set gated values. Suspend: pointer.BoolPtr(true), TTLSecondsAfterFinished: pointer.Int32Ptr(0), - CompletionMode: batch.IndexedCompletion, + CompletionMode: completionModePtr(batch.IndexedCompletion), }, Status: batch.JobStatus{ Active: 11, @@ -117,11 +117,11 @@ func testJobStrategy(t *testing.T) { if ttlEnabled != (job.Spec.TTLSecondsAfterFinished != nil) { t.Errorf("Job should allow setting .spec.ttlSecondsAfterFinished only when %v feature is enabled", features.TTLAfterFinished) } - if indexedJobEnabled != (job.Spec.CompletionMode != batch.NonIndexedCompletion) { - t.Errorf("Job should allow setting .spec.completionMode=Indexed only when %v feature is enabled", features.IndexedJob) + if indexedJobEnabled != (job.Spec.CompletionMode != nil) { + t.Errorf("Job should allow setting .spec.completionMode only when %v feature is enabled", features.IndexedJob) } - if !suspendJobEnabled && *job.Spec.Suspend { - t.Errorf("[SuspendJob=%v] .spec.suspend should be set to true", suspendJobEnabled) + if !suspendJobEnabled && (job.Spec.Suspend != nil) { + t.Errorf("Job should allow setting .spec.suspend only when %v feature is enabled", features.SuspendJob) } parallelism := int32(10) @@ -132,7 +132,7 @@ func testJobStrategy(t *testing.T) { Completions: pointer.Int32Ptr(2), // Update gated features. TTLSecondsAfterFinished: pointer.Int32Ptr(1), - CompletionMode: batch.IndexedCompletion, // No change because field is immutable. + CompletionMode: completionModePtr(batch.IndexedCompletion), // No change because field is immutable. }, Status: batch.JobStatus{ Active: 11, @@ -153,21 +153,10 @@ func testJobStrategy(t *testing.T) { t.Errorf("Expected a validation error") } - // Existing gated fields should be preserved - job.Spec.TTLSecondsAfterFinished = pointer.Int32Ptr(1) - job.Spec.CompletionMode = batch.IndexedCompletion - updatedJob.Spec.TTLSecondsAfterFinished = pointer.Int32Ptr(2) - updatedJob.Spec.CompletionMode = batch.IndexedCompletion // Test updating suspend false->true and nil-> true when the feature gate is // disabled. We don't care about other combinations. job.Spec.Suspend, updatedJob.Spec.Suspend = pointer.BoolPtr(false), pointer.BoolPtr(true) Strategy.PrepareForUpdate(ctx, updatedJob, job) - if job.Spec.TTLSecondsAfterFinished == nil || updatedJob.Spec.TTLSecondsAfterFinished == nil { - t.Errorf("existing .spec.ttlSecondsAfterFinished should be preserved") - } - if job.Spec.CompletionMode == "" || updatedJob.Spec.CompletionMode == "" { - t.Errorf("existing completionMode should be preserved") - } if !suspendJobEnabled && *updatedJob.Spec.Suspend { t.Errorf("[SuspendJob=%v] .spec.suspend should not be updated from false to true", suspendJobEnabled) } @@ -324,3 +313,7 @@ func TestSelectableFieldLabelConversions(t *testing.T) { nil, ) } + +func completionModePtr(m batch.CompletionMode) *batch.CompletionMode { + return &m +} diff --git a/staging/src/k8s.io/api/batch/v1/generated.pb.go b/staging/src/k8s.io/api/batch/v1/generated.pb.go index ef1c0bce6db..1407caebc61 100644 --- a/staging/src/k8s.io/api/batch/v1/generated.pb.go +++ b/staging/src/k8s.io/api/batch/v1/generated.pb.go @@ -344,89 +344,89 @@ func init() { } var fileDescriptor_3b52da57c93de713 = []byte{ - // 1307 bytes of a gzipped FileDescriptorProto - 0x1f, 0x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 0xbf, 0x62, 0x8d, 0x56, 0x27, 0x73, 0x91, 0x41, - 0x7d, 0x92, 0x73, 0x4f, 0x6b, 0x2f, 0xc5, 0x38, 0xd8, 0x38, 0xb5, 0x5c, 0xe2, 0x4f, 0xbb, 0xde, - 0xd9, 0x28, 0x32, 0xb0, 0xae, 0x43, 0x38, 0xce, 0x63, 0x75, 0x8b, 0x58, 0xfe, 0xd8, 0xe5, 0x96, - 0x43, 0x96, 0x08, 0xef, 0xfd, 0x1b, 0x81, 0x19, 0xa7, 0xc4, 0xc1, 0x8b, 0xbc, 0xce, 0xdf, 0x0a, - 0xa8, 0x1c, 0xf8, 0xd4, 0x3d, 0xa4, 0x03, 0xf8, 0x0d, 0xa8, 0x46, 0xfe, 0x98, 0x98, 0xe3, 0xa6, - 0xb2, 0xad, 0xec, 0xd4, 0x6f, 0xbe, 0xa3, 0xa5, 0x51, 0x4a, 0x64, 0x35, 0xef, 0x6c, 0x14, 0x19, - 0x98, 0x16, 0xa1, 0xb5, 0xc9, 0xae, 0x76, 0x77, 0xf0, 0x80, 0x18, 0xfc, 0x88, 0x70, 0xac, 0xc3, - 0x87, 0x81, 0xba, 0x12, 0x06, 0x2a, 0x48, 0x6d, 0x28, 0x51, 0x85, 0x3a, 0x58, 0x63, 0x1e, 0x31, - 0x9a, 0xab, 0x42, 0x7d, 0x5b, 0xcb, 0xc9, 0x81, 0x26, 0xbd, 0xe9, 0x7b, 0xc4, 0xd0, 0x37, 0xa4, - 0xda, 0x5a, 0xf4, 0x85, 0x04, 0x17, 0x1e, 0x82, 0x75, 0xc6, 0x31, 0x1f, 0xb3, 0x66, 0x49, 0xa8, - 0x74, 0x2e, 0x54, 0x11, 0x48, 0x7d, 0x4b, 0xea, 0xac, 0xc7, 0xdf, 0x48, 0x2a, 0x74, 0x7e, 0x52, - 0x40, 0x5d, 0x22, 0x7b, 0x16, 0xe3, 0xf0, 0xfe, 0x52, 0x04, 0xb4, 0xa7, 0x8b, 0x40, 0xc4, 0x16, -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d4, 0x8c, 0xb2, 0x98, 0x88, 0x62, 0x50, 0xc7, 0xb3, 0x49, 0x14, 0xcc, 0xb8, 0xdc, 0x24, 0xe5, - 0x20, 0x35, 0xa3, 0x2c, 0x06, 0xde, 0x05, 0x57, 0xe3, 0x0e, 0xb6, 0x38, 0x01, 0x4b, 0x62, 0x02, - 0xfe, 0x3f, 0x0c, 0xd4, 0xab, 0xfb, 0x79, 0x00, 0x94, 0xcf, 0x83, 0x7b, 0x60, 0x63, 0x80, 0x8d, - 0x33, 0x3a, 0x1c, 0x66, 0x3b, 0x76, 0x23, 0x0c, 0xd4, 0x0d, 0x3d, 0x63, 0x47, 0x73, 0x28, 0xf8, - 0x15, 0xa8, 0x32, 0x62, 0x13, 0x83, 0x53, 0x5f, 0x96, 0xd8, 0xbb, 0x4f, 0x99, 0x15, 0x3c, 0x20, - 0x76, 0x5f, 0x52, 0xf5, 0x0d, 0x31, 0xe9, 0xe5, 0x17, 0x4a, 0x24, 0xe1, 0x07, 0x60, 0xcb, 0xc1, - 0xee, 0x18, 0x27, 0x48, 0x51, 0x5b, 0x55, 0x1d, 0x86, 0x81, 0xba, 0x75, 0x34, 0x77, 0x82, 0x16, - 0x90, 0xf0, 0x33, 0x50, 0xe5, 0xb3, 0x31, 0xba, 0x2e, 0x5c, 0xcb, 0x1d, 0x14, 0xc7, 0xd4, 0x9c, - 0x9b, 0xa2, 0x49, 0x95, 0x24, 0x23, 0x34, 0x91, 0x89, 0x16, 0x0f, 0xce, 0x6d, 0x19, 0xb1, 0xfd, - 0x21, 0x27, 0xfe, 0x6d, 0xcb, 0xb5, 0xd8, 0x29, 0x31, 0x9b, 0x55, 0x11, 0x2e, 0xb1, 0x78, 0x9c, - 0x9c, 0xf4, 0xf2, 0x20, 0xa8, 0x88, 0x0b, 0x8f, 0xc1, 0x56, 0x9a, 0xda, 0x23, 0x6a, 0x92, 0x66, - 0x4d, 0x3c, 0x8c, 0x1d, 0xe9, 0xca, 0xd6, 0xc1, 0xdc, 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, 0xb6, - 0xf2, 0x7b, 0xd8, 0x56, 0xbe, 0xff, 0xa3, 0xbd, 0xf2, 0xc5, 0xea, 0x64, 0xf7, 0x9f, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x3d, 0x6d, 0x62, 0x04, 0x48, 0x0f, 0x00, 0x00, + // 1304 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x41, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0xc6, 0x71, 0x6c, 0x8f, 0x93, 0xd4, 0x9d, 0xd2, 0xd6, 0x98, 0xca, 0x1b, 0x4c, 0x41, + 0x01, 0xc1, 0x9a, 0x94, 0x08, 0x21, 0x04, 0x48, 0xd9, 0x54, 0x15, 0x0d, 0x8e, 0x1a, 0xc6, 0xa9, + 0x90, 0xa0, 0x20, 0xc6, 0xbb, 0x63, 0x67, 0x9b, 0xdd, 0x9d, 0xd5, 0xce, 0xd8, 0x22, 0x37, 0x7e, + 0x02, 0xbf, 0x02, 0x71, 0x42, 0x48, 0xdc, 0x39, 0xa2, 0x1e, 0x7b, 0xec, 0x69, 0x45, 0x97, 0x1b, + 0x17, 0xee, 0xe1, 0x82, 0x76, 0x76, 0xbc, 0xbb, 0xb6, 0x77, 0x43, 0xd3, 0x43, 0xc5, 0xcd, 0xfb, + 0xe6, 0xfb, 0xbe, 0x79, 0x7e, 0xef, 0xcd, 0x7b, 0x0f, 0x7c, 0x74, 0xf2, 0x01, 0xd3, 0x2c, 0xda, + 0x3d, 0x19, 0x0f, 0x88, 0xef, 0x12, 0x4e, 0x58, 0x77, 0x42, 0x5c, 0x93, 0xfa, 0x5d, 0x79, 0x80, + 0x3d, 0xab, 0x3b, 0xc0, 0xdc, 0x38, 0xee, 0x4e, 0xb6, 0xbb, 0x23, 0xe2, 0x12, 0x1f, 0x73, 0x62, + 0x6a, 0x9e, 0x4f, 0x39, 0x85, 0x57, 0x62, 0x90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0x6e, 0x5d, 0xfc, 0xff, + 0xef, 0x03, 0xfa, 0xd6, 0xa3, 0xa7, 0xed, 0xa5, 0xc7, 0x4f, 0xdb, 0x4b, 0x4f, 0x9e, 0xb6, 0x97, + 0xbe, 0x0f, 0xdb, 0xca, 0xa3, 0xb0, 0xad, 0x3c, 0x0e, 0xdb, 0xca, 0x93, 0xb0, 0xad, 0xfc, 0x11, + 0xb6, 0x95, 0x1f, 0xfe, 0x6c, 0x2f, 0x7d, 0xb9, 0x3c, 0xd9, 0xfe, 0x37, 0x00, 0x00, 0xff, 0xff, + 0x5a, 0x54, 0xec, 0x5f, 0x44, 0x0f, 0x00, 0x00, } func (m *CronJob) Marshal() (dAtA []byte, err error) { @@ -851,11 +851,13 @@ func (m *JobSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x50 } - i -= len(m.CompletionMode) - copy(dAtA[i:], m.CompletionMode) - i = encodeVarintGenerated(dAtA, i, uint64(len(m.CompletionMode))) - i-- - dAtA[i] = 0x4a + if m.CompletionMode != nil { + i -= len(*m.CompletionMode) + copy(dAtA[i:], *m.CompletionMode) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.CompletionMode))) + i-- + dAtA[i] = 0x4a + } if m.TTLSecondsAfterFinished != nil { i = encodeVarintGenerated(dAtA, i, uint64(*m.TTLSecondsAfterFinished)) i-- @@ -1210,8 +1212,10 @@ func (m *JobSpec) Size() (n int) { if m.TTLSecondsAfterFinished != nil { n += 1 + sovGenerated(uint64(*m.TTLSecondsAfterFinished)) } - l = len(m.CompletionMode) - n += 1 + l + sovGenerated(uint64(l)) + if m.CompletionMode != nil { + l = len(*m.CompletionMode) + n += 1 + l + sovGenerated(uint64(l)) + } if m.Suspend != nil { n += 2 } @@ -1382,7 +1386,7 @@ func (this *JobSpec) String() string { `Template:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Template), "PodTemplateSpec", "v11.PodTemplateSpec", 1), `&`, ``, 1) + `,`, `BackoffLimit:` + valueToStringGenerated(this.BackoffLimit) + `,`, `TTLSecondsAfterFinished:` + valueToStringGenerated(this.TTLSecondsAfterFinished) + `,`, - `CompletionMode:` + fmt.Sprintf("%v", this.CompletionMode) + `,`, + `CompletionMode:` + valueToStringGenerated(this.CompletionMode) + `,`, `Suspend:` + valueToStringGenerated(this.Suspend) + `,`, `}`, }, "") @@ -2837,7 +2841,8 @@ func (m *JobSpec) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.CompletionMode = CompletionMode(dAtA[iNdEx:postIndex]) + s := CompletionMode(dAtA[iNdEx:postIndex]) + m.CompletionMode = &s iNdEx = postIndex case 10: if wireType != 0 { diff --git a/staging/src/k8s.io/api/batch/v1/types.go b/staging/src/k8s.io/api/batch/v1/types.go index 7a922564089..12f4b04cbd9 100644 --- a/staging/src/k8s.io/api/batch/v1/types.go +++ b/staging/src/k8s.io/api/batch/v1/types.go @@ -168,7 +168,7 @@ type JobSpec struct { // If the Job controller observes a mode that it doesn't recognize, the // controller skips updates for the Job. // +optional - CompletionMode CompletionMode `json:"completionMode,omitempty" protobuf:"bytes,9,opt,name=completionMode,casttype=CompletionMode"` + CompletionMode *CompletionMode `json:"completionMode,omitempty" protobuf:"bytes,9,opt,name=completionMode,casttype=CompletionMode"` // Suspend specifies whether the Job controller should create Pods or not. If // a Job is created with suspend set to true, no Pods are created by the Job diff --git a/staging/src/k8s.io/api/batch/v1/zz_generated.deepcopy.go b/staging/src/k8s.io/api/batch/v1/zz_generated.deepcopy.go index 96f012532f5..6018ad1d3c0 100644 --- a/staging/src/k8s.io/api/batch/v1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/api/batch/v1/zz_generated.deepcopy.go @@ -271,6 +271,11 @@ func (in *JobSpec) DeepCopyInto(out *JobSpec) { *out = new(int32) **out = **in } + if in.CompletionMode != nil { + in, out := &in.CompletionMode, &out.CompletionMode + *out = new(CompletionMode) + **out = **in + } if in.Suspend != nil { in, out := &in.Suspend, &out.Suspend *out = new(bool) diff --git a/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.json b/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.json index f6880296146..aa307a224e8 100644 --- a/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.json +++ b/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.json @@ -1577,11 +1577,12 @@ } }, "ttlSecondsAfterFinished": -1285029915, - "suspend": true + "completionMode": "{ȃ騑ȫ(踶NJđƟÝɹ橽ƴåj}c殶", + "suspend": false } }, - "successfulJobsHistoryLimit": 1729066291, - "failedJobsHistoryLimit": -908823020 + "successfulJobsHistoryLimit": -2006986560, + "failedJobsHistoryLimit": -380889943 }, "status": { "active": [ @@ -1589,7 +1590,7 @@ "kind": "505", "namespace": "506", "name": "507", - "uid": "`", + "uid": "暉Ŝ!ȣ绰", "apiVersion": "508", "resourceVersion": "509", "fieldPath": "510" diff --git a/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.pb b/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.pb index 1046ff93e50..f8160dc80fe 100644 Binary files a/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.pb and b/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.pb differ diff --git a/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.yaml b/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.yaml index 5d20489ebc7..ac710e6eda9 100644 --- a/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.yaml +++ b/staging/src/k8s.io/api/testdata/HEAD/batch.v1.CronJob.yaml @@ -31,7 +31,7 @@ metadata: uid: "7" spec: concurrencyPolicy: Hr鯹)晿桼劑 + type: 穌砊ʑȩ硘(ǒ[ȼ罦¦褅 + failed: 648978003 + succeeded: -702718077 diff --git a/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.json b/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.json index 2c05dab5599..66aa941a639 100644 --- a/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.json +++ b/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.json @@ -1577,11 +1577,12 @@ } }, "ttlSecondsAfterFinished": -1285029915, - "suspend": true + "completionMode": "{ȃ騑ȫ(踶NJđƟÝɹ橽ƴåj}c殶", + "suspend": false } }, - "successfulJobsHistoryLimit": 1729066291, - "failedJobsHistoryLimit": -908823020 + "successfulJobsHistoryLimit": -2006986560, + "failedJobsHistoryLimit": -380889943 }, "status": { "active": [ @@ -1589,7 +1590,7 @@ "kind": "505", "namespace": "506", "name": "507", - "uid": "`", + "uid": "暉Ŝ!ȣ绰", "apiVersion": "508", "resourceVersion": "509", "fieldPath": "510" diff --git a/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.pb b/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.pb index 4b7a537b7b9..5053c8251fa 100644 Binary files a/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.pb and b/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.pb differ diff --git a/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.yaml b/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.yaml index 43dd134ad82..99c992127bf 100644 --- a/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.yaml +++ b/staging/src/k8s.io/api/testdata/HEAD/batch.v1beta1.CronJob.yaml @@ -31,7 +31,7 @@ metadata: uid: "7" spec: concurrencyPolicy: Hr鯹)晿\n") } - if job.Spec.CompletionMode != "" { + if job.Spec.CompletionMode != nil { w.Write(LEVEL_0, "Completion Mode:\t%s\n", job.Spec.CompletionMode) } if job.Status.StartTime != nil { @@ -2181,7 +2181,7 @@ func describeJob(job *batchv1.Job, events *corev1.EventList) (string, error) { w.Write(LEVEL_0, "Active Deadline Seconds:\t%ds\n", *job.Spec.ActiveDeadlineSeconds) } w.Write(LEVEL_0, "Pods Statuses:\t%d Running / %d Succeeded / %d Failed\n", job.Status.Active, job.Status.Succeeded, job.Status.Failed) - if job.Spec.CompletionMode == batchv1.IndexedCompletion { + if job.Spec.CompletionMode != nil && *job.Spec.CompletionMode == batchv1.IndexedCompletion { w.Write(LEVEL_0, "Completed Indexes:\t%s\n", capIndexesListOrNone(job.Status.CompletedIndexes, 50)) } DescribePodTemplate(&job.Spec.Template, w) diff --git a/staging/src/k8s.io/kubectl/pkg/describe/describe_test.go b/staging/src/k8s.io/kubectl/pkg/describe/describe_test.go index 487decf7e57..73124205b77 100644 --- a/staging/src/k8s.io/kubectl/pkg/describe/describe_test.go +++ b/staging/src/k8s.io/kubectl/pkg/describe/describe_test.go @@ -2065,6 +2065,7 @@ func TestDescribeDeployment(t *testing.T) { } func TestDescribeJob(t *testing.T) { + indexedCompletion := batchv1.IndexedCompletion cases := map[string]struct { job *batchv1.Job wantCompletedIndexes string @@ -2075,9 +2076,7 @@ func TestDescribeJob(t *testing.T) { Name: "bar", Namespace: "foo", }, - Spec: batchv1.JobSpec{ - CompletionMode: batchv1.NonIndexedCompletion, - }, + Spec: batchv1.JobSpec{}, }, }, "no indexes": { @@ -2087,7 +2086,7 @@ func TestDescribeJob(t *testing.T) { Namespace: "foo", }, Spec: batchv1.JobSpec{ - CompletionMode: batchv1.IndexedCompletion, + CompletionMode: &indexedCompletion, }, }, wantCompletedIndexes: "", @@ -2099,7 +2098,7 @@ func TestDescribeJob(t *testing.T) { Namespace: "foo", }, Spec: batchv1.JobSpec{ - CompletionMode: batchv1.IndexedCompletion, + CompletionMode: &indexedCompletion, }, Status: batchv1.JobStatus{ CompletedIndexes: "0-5,7,9,10,12,13,15,16,18,20,21,23,24,26,27,29,30,32", @@ -2114,7 +2113,7 @@ func TestDescribeJob(t *testing.T) { Namespace: "foo", }, Spec: batchv1.JobSpec{ - CompletionMode: batchv1.IndexedCompletion, + CompletionMode: &indexedCompletion, }, Status: batchv1.JobStatus{ CompletedIndexes: "0-5,7,9,10,12,13,15,16,18,20,21,23,24,26,27,29,30,32-34,36,37", diff --git a/test/e2e/apps/job.go b/test/e2e/apps/job.go index 2d01900a313..d5468945bfb 100644 --- a/test/e2e/apps/job.go +++ b/test/e2e/apps/job.go @@ -156,7 +156,8 @@ var _ = SIGDescribe("Job", func() { ginkgo.It("[Feature:IndexedJob] should create pods for an Indexed job with completion indexes", func() { ginkgo.By("Creating Indexed job") job := e2ejob.NewTestJob("succeed", "indexed-job", v1.RestartPolicyNever, parallelism, completions, nil, backoffLimit) - job.Spec.CompletionMode = batchv1.IndexedCompletion + mode := batchv1.IndexedCompletion + job.Spec.CompletionMode = &mode job, err := e2ejob.CreateJob(f.ClientSet, f.Namespace.Name, job) framework.ExpectNoError(err, "failed to create indexed job in namespace %s", f.Namespace.Name) diff --git a/test/integration/job/job_test.go b/test/integration/job/job_test.go index fbc243e57b9..b77e6d38094 100644 --- a/test/integration/job/job_test.go +++ b/test/integration/job/job_test.go @@ -200,11 +200,12 @@ func TestIndexedJob(t *testing.T) { cancel() }() + mode := batchv1.IndexedCompletion jobObj, err := createJobWithDefaults(ctx, clientSet, ns.Name, &batchv1.Job{ Spec: batchv1.JobSpec{ Parallelism: pointer.Int32Ptr(3), Completions: pointer.Int32Ptr(4), - CompletionMode: batchv1.IndexedCompletion, + CompletionMode: &mode, }, }) if err != nil {