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

Add PVC bound check #32

Merged
merged 2 commits into from
May 7, 2024
Merged

Conversation

arnongilboa
Copy link
Collaborator

@arnongilboa arnongilboa commented Apr 17, 2024

Add a check that we can create a 20MiB PVC of the configured/default storage class and it will be bound by the provisioner.

Also add optional checkup params:
spec.param.storageClass - optional storage class to be used instead of the default one (needed for the new check).
spec.param.vmiTimeout - optional timeout for VMI operations (the default is 3min).

Copy link
Collaborator

@ShellyKa13 ShellyKa13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi let me be a bit pedantic :) and ask that you add description for the PR and explanation in the commit message of what you did here. And also you added and changed params that are not related to PVC bound check and they are hidden in the commit and PR, such as the vmiTimeout and storageclass, it should have received separate commits with explanations.

@@ -342,14 +350,18 @@ func isDataSourceReady(conditions []cdiv1.DataSourceCondition) bool {
return false
}

func (c *Checkup) updategoldenImagePvc(pvc *corev1.PersistentVolumeClaim, cs *goldenImagesCheckState) {
func (c *Checkup) updateGoldenImagePvc(pvc *corev1.PersistentVolumeClaim, cs *goldenImagesCheckState) {
if pvc == nil {
return
}

// Prefer golden image with default SC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer golden image with **configured**/ default SC

if pvc == nil {
return
}

// Prefer golden image with default SC
if c.goldenImagePvc != nil {
if sc := c.goldenImagePvc.Spec.StorageClassName; sc == nil || *sc == c.results.DefaultStorageClass {
sc := c.goldenImagePvc.Spec.StorageClassName
if c.checkupConfig.StorageClass != "" && sc != nil && *sc == c.checkupConfig.StorageClass {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but, how about:
if sc == nil{
return
}
if *sc == c.results.DefaultStorageClass ||
(c.checkupConfig.StorageClass != "" && *sc == c.checkupConfig.StorageClass) {

AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceStorage: resource.MustParse("10Mi"),
Copy link
Collaborator

@ShellyKa13 ShellyKa13 Apr 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already know that there are some provisioners that needs at least 20Mi

@@ -390,6 +402,61 @@ func (c *Checkup) checkDefaultStorageClass(scs *storagev1.StorageClassList, errS
}
}

func (c *Checkup) checkPVCBound(ctx context.Context, errStr *string) error {
log.Print("checkPVCCreation")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe even more specific print of checkPVCCreationAndBinding

}

if sc := c.checkupConfig.StorageClass; sc != "" {
log.Printf("PVC storage class %q", sc)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didnt knew this %q option :) thanks

}

log.Printf("Waiting for PVC %q bound", pvcName)
if err := wait.PollImmediateWithContext(ctx, pollInterval, time.Minute, conditionFn); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in case the provisioner binding mode is WFFC we are returning error? why is this the desired behavior?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we better create DV with cdi.kubevirt.io/storage.bind.immediate.requested: "true" instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure what we want to test exactly.. so I guess is depends

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all we want to check is that a PVC of the configured/default SC can be successfully bound

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok then I guess yes we should use the bind annotation

PodUID: baseConfig.PodUID,
PodName: baseConfig.PodName,
PodUID: baseConfig.PodUID,
StorageClass: baseConfig.Params[StorageClassParamName],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think since storageclass is also optional you shouldnt set it here, but you should do it in the set optional params.. I know that in the current way it will also be empty if it wasnt set but code wise its a bit confusing.

Add a check that we can create a 20MiB PVC of the default storage class
and it will be bound by the provisioner.

Signed-off-by: Arnon Gilboa <[email protected]>
- spec.param.storageClass - optional storage class to be used instead of
the default one.
- spec.param.vmiTimeout - optional timeout for VMI operations (the
default is 3min).

Signed-off-by: Arnon Gilboa <[email protected]>
Copy link
Collaborator

@ShellyKa13 ShellyKa13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@arnongilboa arnongilboa merged commit 1f44acf into kiagnose:main May 7, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants