plumb feature gate value through job validation opts and modify validateCompletions function to only check completions == parallelism after the update, not before

This commit is contained in:
Daniel Vega-Myhre
2023-02-23 03:20:52 +00:00
parent c63f448451
commit 15077a0f28
3 changed files with 33 additions and 16 deletions

View File

@@ -1298,6 +1298,9 @@ func TestValidateJobUpdate(t *testing.T) {
job.Spec.Completions = pointer.Int32Ptr(2)
job.Spec.Parallelism = pointer.Int32Ptr(2)
},
opts: JobValidationOptions{
AllowElasticIndexedJobs: true,
},
},
"previous parallelism != previous completions, new parallelism == new completions": {
old: batch.Job{
@@ -1314,9 +1317,8 @@ func TestValidateJobUpdate(t *testing.T) {
job.Spec.Completions = pointer.Int32Ptr(3)
job.Spec.Parallelism = pointer.Int32Ptr(3)
},
err: &field.Error{
Type: field.ErrorTypeInvalid,
Field: "spec.completions",
opts: JobValidationOptions{
AllowElasticIndexedJobs: true,
},
},
"indexed job updating completions and parallelism to different values is invalid": {
@@ -1334,6 +1336,9 @@ func TestValidateJobUpdate(t *testing.T) {
job.Spec.Completions = pointer.Int32Ptr(2)
job.Spec.Parallelism = pointer.Int32Ptr(3)
},
opts: JobValidationOptions{
AllowElasticIndexedJobs: true,
},
err: &field.Error{
Type: field.ErrorTypeInvalid,
Field: "spec.completions",
@@ -1354,6 +1359,9 @@ func TestValidateJobUpdate(t *testing.T) {
job.Spec.Completions = nil
job.Spec.Parallelism = pointer.Int32Ptr(3)
},
opts: JobValidationOptions{
AllowElasticIndexedJobs: true,
},
err: &field.Error{
Type: field.ErrorTypeRequired,
Field: "spec.completions",
@@ -1374,6 +1382,9 @@ func TestValidateJobUpdate(t *testing.T) {
job.Spec.Completions = pointer.Int32Ptr(2)
job.Spec.Parallelism = pointer.Int32Ptr(1)
},
opts: JobValidationOptions{
AllowElasticIndexedJobs: true,
},
},
"indexed job with completions unchanged, parallelism increased higher than completions": {
old: batch.Job{
@@ -1390,6 +1401,9 @@ func TestValidateJobUpdate(t *testing.T) {
job.Spec.Completions = pointer.Int32Ptr(2)
job.Spec.Parallelism = pointer.Int32Ptr(3)
},
opts: JobValidationOptions{
AllowElasticIndexedJobs: true,
},
},
}
ignoreValueAndDetail := cmpopts.IgnoreFields(field.Error{}, "BadValue", "Detail")