mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
add validation test case for immutable completions on indexed jobs when AllowElasticIndexedJobs is false
This commit is contained in:
parent
15077a0f28
commit
8d31da4599
@ -935,6 +935,22 @@ func TestValidateJobUpdate(t *testing.T) {
|
||||
Field: "spec.completions",
|
||||
},
|
||||
},
|
||||
"immutable completions for indexed job when AllowElasticIndexedJobs is false": {
|
||||
old: batch.Job{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
|
||||
Spec: batch.JobSpec{
|
||||
Selector: validGeneratedSelector,
|
||||
Template: validPodTemplateSpecForGenerated,
|
||||
},
|
||||
},
|
||||
update: func(job *batch.Job) {
|
||||
job.Spec.Completions = pointer.Int32Ptr(1)
|
||||
},
|
||||
err: &field.Error{
|
||||
Type: field.ErrorTypeInvalid,
|
||||
Field: "spec.completions",
|
||||
},
|
||||
},
|
||||
"immutable selector": {
|
||||
old: batch.Job{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
|
||||
|
@ -184,11 +184,10 @@ func validationOptionsForJob(newJob, oldJob *batch.Job) batchvalidation.JobValid
|
||||
notStarted := oldJob.Status.StartTime == nil
|
||||
opts.AllowMutableSchedulingDirectives = utilfeature.DefaultFeatureGate.Enabled(features.JobMutableNodeSchedulingDirectives) &&
|
||||
suspended && notStarted
|
||||
|
||||
// Elastic indexed jobs (mutable completions iff updated parallelism == updated completions)
|
||||
opts.AllowElasticIndexedJobs = utilfeature.DefaultFeatureGate.Enabled(features.ElasticIndexedJob)
|
||||
}
|
||||
|
||||
// Elastic indexed jobs (mutable completions iff updated parallelism == updated completions)
|
||||
opts.AllowElasticIndexedJobs = utilfeature.DefaultFeatureGate.Enabled(features.ElasticIndexedJob)
|
||||
return opts
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user