-
Notifications
You must be signed in to change notification settings - Fork 1
fix(vi): validate VirtualImage
storage class
#852
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
base: main
Are you sure you want to change the base?
Conversation
1a24522
to
bdbb8dc
Compare
Signed-off-by: Roman Sysoev <roman.sysoev@flant.com>
bdbb8dc
to
eb2917a
Compare
@@ -114,3 +131,36 @@ func (v *Validator) ValidateDelete(_ context.Context, _ runtime.Object) (admissi | |||
v.logger.Error("Ensure the correctness of ValidatingWebhookConfiguration", "err", err) | |||
return nil, nil | |||
} | |||
|
|||
func (v *Validator) validateStorageClass(ctx context.Context, vi *virtv2.VirtualImage) (admission.Warnings, error) { | |||
if vi.Spec.PersistentVolumeClaim != (virtv2.VirtualImagePersistentVolumeClaim{}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you decide not to check vi.Spec.Storage if vi.Spec.PersistentVolumeClaim is empty?
@@ -114,3 +131,36 @@ func (v *Validator) ValidateDelete(_ context.Context, _ runtime.Object) (admissi | |||
v.logger.Error("Ensure the correctness of ValidatingWebhookConfiguration", "err", err) | |||
return nil, nil | |||
} | |||
|
|||
func (v *Validator) validateStorageClass(ctx context.Context, vi *virtv2.VirtualImage) (admission.Warnings, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to check and prevent the creation of images not only for the storage class from the spec but also for default storage classes. This way, the user won't wait unnecessarily for an image that will never be created. Or was this check intentionally not added?
if len(scProfile.Status.ClaimPropertySets) == 0 { | ||
return reconcile.Result{}, fmt.Errorf("failed to validate the `PersistentVolumeMode` of the `StorageProfile`: %s", sc.Name) | ||
} | ||
if *scProfile.Status.ClaimPropertySets[0].VolumeMode == corev1.PersistentVolumeFilesystem { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the test case to ensure that the condition will be false if the storage class is not ReadWriteMany and Block.
Description
A temporary solution until the problem with
PersistentVolumeMode
is resolved.Why do we need it, and what problem does it solve?
This is currently required to prevent a
VirtualImage
from being created with thePersistentVolumeFilesystem
storage class.What is the expected result?
VirtualImage
cannot be created thePersistentVolumeFilesystem
storage class.Checklist
Changelog entries