Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of #80945: Validate CSI Inline Migration unconditionally #81038

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions pkg/apis/storage/validation/validation.go
Expand Up @@ -187,11 +187,7 @@ func validateVolumeAttachmentSource(source *storage.VolumeAttachmentSource, fldP
allErrs = append(allErrs, field.Required(fldPath.Child("persistentVolumeName"), "must specify non empty persistentVolumeName"))
}
case source.InlineVolumeSpec != nil:
if utilfeature.DefaultFeatureGate.Enabled(features.CSIMigration) {
allErrs = append(allErrs, storagevalidation.ValidatePersistentVolumeSpec(source.InlineVolumeSpec, "", true, fldPath.Child("inlineVolumeSpec"))...)
} else {
allErrs = append(allErrs, field.Forbidden(fldPath, "may not specify inlineVolumeSpec when CSIMigration feature is disabled"))
}
allErrs = append(allErrs, storagevalidation.ValidatePersistentVolumeSpec(source.InlineVolumeSpec, "", true, fldPath.Child("inlineVolumeSpec"))...)
}
return allErrs
}
Expand Down
16 changes: 3 additions & 13 deletions pkg/apis/storage/validation/validation_test.go
Expand Up @@ -393,14 +393,6 @@ func TestVolumeAttachmentValidation(t *testing.T) {
},
},
},
}
for _, volumeAttachment := range migrationDisabledSuccessCases {
if errs := ValidateVolumeAttachment(&volumeAttachment); len(errs) != 0 {
t.Errorf("expected success: %v %v", volumeAttachment, errs)
}
}

migrationDisabledErrorCases := []storage.VolumeAttachment{
{
// InlineSpec specified with migration disabled
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
Expand All @@ -413,13 +405,11 @@ func TestVolumeAttachmentValidation(t *testing.T) {
},
},
}

for _, volumeAttachment := range migrationDisabledErrorCases {
if errs := ValidateVolumeAttachment(&volumeAttachment); len(errs) == 0 {
t.Errorf("expected failure: %v %v", volumeAttachment, errs)
for _, volumeAttachment := range migrationDisabledSuccessCases {
if errs := ValidateVolumeAttachment(&volumeAttachment); len(errs) != 0 {
t.Errorf("expected success: %v %v", volumeAttachment, errs)
}
}

}

func TestVolumeAttachmentUpdateValidation(t *testing.T) {
Expand Down