Skip to content

Commit 6049253

Browse files
authored
Merge pull request kubernetes#80945 from tedyu/uncond-validate
Validate CSI Inline Migration unconditionally
2 parents 7c23e1a + bb77aa7 commit 6049253

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

pkg/apis/storage/validation/validation.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,7 @@ func validateVolumeAttachmentSource(source *storage.VolumeAttachmentSource, fldP
187187
allErrs = append(allErrs, field.Required(fldPath.Child("persistentVolumeName"), "must specify non empty persistentVolumeName"))
188188
}
189189
case source.InlineVolumeSpec != nil:
190-
if utilfeature.DefaultFeatureGate.Enabled(features.CSIMigration) {
191-
allErrs = append(allErrs, storagevalidation.ValidatePersistentVolumeSpec(source.InlineVolumeSpec, "", true, fldPath.Child("inlineVolumeSpec"))...)
192-
} else {
193-
allErrs = append(allErrs, field.Forbidden(fldPath, "may not specify inlineVolumeSpec when CSIMigration feature is disabled"))
194-
}
190+
allErrs = append(allErrs, storagevalidation.ValidatePersistentVolumeSpec(source.InlineVolumeSpec, "", true, fldPath.Child("inlineVolumeSpec"))...)
195191
}
196192
return allErrs
197193
}

pkg/apis/storage/validation/validation_test.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,6 @@ func TestVolumeAttachmentValidation(t *testing.T) {
394394
},
395395
},
396396
},
397-
}
398-
for _, volumeAttachment := range migrationDisabledSuccessCases {
399-
if errs := ValidateVolumeAttachment(&volumeAttachment); len(errs) != 0 {
400-
t.Errorf("expected success: %v %v", volumeAttachment, errs)
401-
}
402-
}
403-
404-
migrationDisabledErrorCases := []storage.VolumeAttachment{
405397
{
406398
// InlineSpec specified with migration disabled
407399
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
@@ -414,13 +406,11 @@ func TestVolumeAttachmentValidation(t *testing.T) {
414406
},
415407
},
416408
}
417-
418-
for _, volumeAttachment := range migrationDisabledErrorCases {
419-
if errs := ValidateVolumeAttachment(&volumeAttachment); len(errs) == 0 {
420-
t.Errorf("expected failure: %v %v", volumeAttachment, errs)
409+
for _, volumeAttachment := range migrationDisabledSuccessCases {
410+
if errs := ValidateVolumeAttachment(&volumeAttachment); len(errs) != 0 {
411+
t.Errorf("expected success: %v %v", volumeAttachment, errs)
421412
}
422413
}
423-
424414
}
425415

426416
func TestVolumeAttachmentUpdateValidation(t *testing.T) {

0 commit comments

Comments
 (0)