mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +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",
|
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": {
|
"immutable selector": {
|
||||||
old: batch.Job{
|
old: batch.Job{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
|
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
|
notStarted := oldJob.Status.StartTime == nil
|
||||||
opts.AllowMutableSchedulingDirectives = utilfeature.DefaultFeatureGate.Enabled(features.JobMutableNodeSchedulingDirectives) &&
|
opts.AllowMutableSchedulingDirectives = utilfeature.DefaultFeatureGate.Enabled(features.JobMutableNodeSchedulingDirectives) &&
|
||||||
suspended && notStarted
|
suspended && notStarted
|
||||||
|
}
|
||||||
|
|
||||||
// Elastic indexed jobs (mutable completions iff updated parallelism == updated completions)
|
// Elastic indexed jobs (mutable completions iff updated parallelism == updated completions)
|
||||||
opts.AllowElasticIndexedJobs = utilfeature.DefaultFeatureGate.Enabled(features.ElasticIndexedJob)
|
opts.AllowElasticIndexedJobs = utilfeature.DefaultFeatureGate.Enabled(features.ElasticIndexedJob)
|
||||||
}
|
|
||||||
|
|
||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user