diff --git a/pkg/api/testing/fuzzer.go b/pkg/api/testing/fuzzer.go index f48aca43585..73b54762eab 100644 --- a/pkg/api/testing/fuzzer.go +++ b/pkg/api/testing/fuzzer.go @@ -169,6 +169,14 @@ func FuzzerFor(t *testing.T, version unversioned.GroupVersion, src rand.Source) j.ManualSelector = nil } }, + func(sj *batch.ScheduledJobSpec, c fuzz.Continue) { + c.FuzzNoCustom(sj) + suspend := c.RandBool() + sj.Suspend = &suspend + sds := int64(c.RandUint64()) + sj.StartingDeadlineSeconds = &sds + sj.Schedule = c.RandString() + }, func(cp *batch.ConcurrencyPolicy, c fuzz.Continue) { policies := []batch.ConcurrencyPolicy{batch.AllowConcurrent, batch.ForbidConcurrent, batch.ReplaceConcurrent} *cp = policies[c.Rand.Intn(len(policies))] diff --git a/pkg/apis/batch/types.go b/pkg/apis/batch/types.go index 61a35d47fa7..7db3057bebc 100644 --- a/pkg/apis/batch/types.go +++ b/pkg/apis/batch/types.go @@ -209,7 +209,7 @@ type ScheduledJobSpec struct { // Suspend flag tells the controller to suspend subsequent executions, it does // not apply to already started executions. Defaults to false. - Suspend *bool `json:"suspend"` + Suspend *bool `json:"suspend,omitempty"` // JobTemplate is the object that describes the job that will be created when // executing a ScheduledJob. diff --git a/pkg/apis/batch/v2alpha1/defaults.go b/pkg/apis/batch/v2alpha1/defaults.go index a7d24ceac91..42f820074b8 100644 --- a/pkg/apis/batch/v2alpha1/defaults.go +++ b/pkg/apis/batch/v2alpha1/defaults.go @@ -46,4 +46,7 @@ func SetDefaults_ScheduledJob(obj *ScheduledJob) { if obj.Spec.ConcurrencyPolicy == "" { obj.Spec.ConcurrencyPolicy = AllowConcurrent } + if obj.Spec.Suspend == nil { + obj.Spec.Suspend = new(bool) + } } diff --git a/pkg/apis/batch/v2alpha1/types.go b/pkg/apis/batch/v2alpha1/types.go index 0402df2e813..ce44235f2d5 100644 --- a/pkg/apis/batch/v2alpha1/types.go +++ b/pkg/apis/batch/v2alpha1/types.go @@ -211,7 +211,7 @@ type ScheduledJobSpec struct { // Suspend flag tells the controller to suspend subsequent executions, it does // not apply to already started executions. Defaults to false. - Suspend *bool `json:"suspend" protobuf:"varint,4,opt,name=suspend"` + Suspend *bool `json:"suspend,omitempty" protobuf:"varint,4,opt,name=suspend"` // JobTemplate is the object that describes the job that will be created when // executing a ScheduledJob.