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

Address possible nils in dv controller, log CSIDrivers in tests #2253

Merged
merged 2 commits into from
Oct 19, 2022

Conversation

akalenyu
Copy link
Collaborator

@akalenyu akalenyu commented May 1, 2022

Signed-off-by: Alex Kalenyuk akalenyu@redhat.com

What this PR does / why we need it:

  • Handle some storageClassName nils
  • We'd expect the CSIDriver object to be there, otherwise ceph install might be struggling

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Release note:

NONE

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/M labels May 1, 2022
@akalenyu akalenyu marked this pull request as draft May 1, 2022 11:05
@akalenyu
Copy link
Collaborator Author

akalenyu commented May 1, 2022

/test pull-containerized-data-importer-e2e-ceph

3 similar comments
@akalenyu
Copy link
Collaborator Author

akalenyu commented May 1, 2022

/test pull-containerized-data-importer-e2e-ceph

@akalenyu
Copy link
Collaborator Author

akalenyu commented May 2, 2022

/test pull-containerized-data-importer-e2e-ceph

@akalenyu
Copy link
Collaborator Author

akalenyu commented May 2, 2022

/test pull-containerized-data-importer-e2e-ceph

@akalenyu
Copy link
Collaborator Author

akalenyu commented May 2, 2022

/test pull-containerized-data-importer-e2e-ceph

@kubevirt-bot kubevirt-bot added size/L and removed size/M labels May 2, 2022
@akalenyu akalenyu force-pushed the debug-ceph-csidriver branch 2 times, most recently from 3b08e10 to e637a2b Compare May 2, 2022 17:55
@akalenyu
Copy link
Collaborator Author

akalenyu commented May 2, 2022

/test all

2 similar comments
@akalenyu
Copy link
Collaborator Author

akalenyu commented May 2, 2022

/test all

@akalenyu
Copy link
Collaborator Author

akalenyu commented May 3, 2022

/test all

@akalenyu
Copy link
Collaborator Author

akalenyu commented May 3, 2022

/retest

@akalenyu akalenyu changed the title [WIP] Debug ceph csidriver not being there Address possible nils in dv controller, log CSIDrivers in tests May 4, 2022
@akalenyu akalenyu marked this pull request as ready for review May 4, 2022 09:07
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 4, 2022
@kubevirt-bot kubevirt-bot requested a review from maya-r May 4, 2022 09:07
if err != nil {
return reconcile.Result{}, err
}
if storageClass == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

So previously, in the case of host-assisted clone, it would go forward and create a PVC -> line 530 (even without a default storageclass, and without storage class defined), now it will return here with error.

Is this the way we want to handle this case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah definitely want to avoid logical changes. I think I took this too far, trying to reuse the storage class that gets passed around.

I'll have another go with more direct approach

if selectedCloneStrategy == SmartClone {
snapshotClassName, _ := r.getSnapshotClassForSmartClone(datavolume, pvcSpec)
snapshotClassName, _ := r.getSnapshotClassForSmartClone(datavolume, storageClass)
return r.reconcileSmartClonePvc(log, datavolume, pvcSpec, transferName, snapshotClassName)
}
if selectedCloneStrategy == CsiClone {
Copy link
Contributor

@brybacki brybacki May 4, 2022

Choose a reason for hiding this comment

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

In theory we should not be able to get SmartClone if there is no storageClass/defaultStoratgeClass, so it should not get here.
Anyway, there is an error we ignore here. Maybe we should not?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, maybe we should look into the selectCloneStrategy and revise what is returned in case there is no StorageClass.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I think we shouldn't have ignored the error.
I minimized the scope of this commit to handle the nils without altering logic too much

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@brybacki Should be strictly about avoiding nils now. let me know what you think

return reconcile.Result{}, err
}
if storageClass == nil {
log.Info("Could not find a default storage class in the cluster")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be better to remove the word "default" and add the SC name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep, changed it to adjust the event message according to if we have the sc name or not

Comment on lines 1542 to 1543
Expect(err).To(Not(HaveOccurred()))
Expect(result).To(Not(BeNil()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use ToNot() instead

reconciler.extClientSet = extfake.NewSimpleClientset(createVolumeSnapshotContentCrd(), createVolumeSnapshotClassCrd(), createVolumeSnapshotCrd())

By("Reconcile")
result, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: types.NamespacedName{Name: "test-dv", Namespace: metav1.NamespaceDefault}})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use dv.Name and dv.Namespace here

Comment on lines 1 to 9
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["metrics.go"],
importpath = "kubevirt.io/containerized-data-importer/pkg/monitoring",
visibility = ["//visibility:public"],
deps = ["//pkg/common:go_default_library"],
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you sure this is needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah but it already got added here #2226
one of the make targets re-adds this, not sure which one

Copy link
Collaborator Author

@akalenyu akalenyu May 18, 2022

Choose a reason for hiding this comment

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

Rebased and this is now gone from my PR

@brybacki
Copy link
Contributor

/test pull-cdi-apidocs

@awels
Copy link
Member

awels commented Jul 8, 2022

Does this still need to get in or did we solve it some other way?

@akalenyu
Copy link
Collaborator Author

Does this still need to get in or did we solve it some other way?

This NPE is still possible afaik

@awels
Copy link
Member

awels commented Aug 3, 2022

/retest

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 11, 2022
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 11, 2022
We'd expect the CSIDriver object to be there, otherwise ceph install might be struggling

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
@@ -772,6 +772,7 @@ func (r *KubernetesReporter) Dump(kubeCli *kubernetes.Clientset, cdiClient *cdiC
return
}

r.logCSIDrivers(kubeCli)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -1886,6 +1897,9 @@ func (r *DatavolumeReconciler) validateAdvancedCloneSizeCompatible(
sourcePvc *corev1.PersistentVolumeClaim,
targetStorageSpec *corev1.PersistentVolumeClaimSpec) (bool, error) {
srcStorageClass := &storagev1.StorageClass{}
if sourcePvc.Spec.StorageClassName == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

is StorageClassName required for advancedClone to work (CSI and Snapshot)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was just protecting nil access in the following line

if err := r.client.Get(context.TODO(), types.NamespacedName{Name: *sourcePvc.Spec.StorageClassName}, srcStorageClass); IgnoreNotFound(err) != nil {

But this is a good question - I think that a GET from our cache should return PVCs that already have a storage class name populated

Copy link
Member

Choose a reason for hiding this comment

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

Storage class is only optional for manually created PVs

@brybacki
Copy link
Contributor

brybacki commented Oct 3, 2022

I think now it looks really good, just one question about source PVC storage class.

@akalenyu
Copy link
Collaborator Author

akalenyu commented Oct 19, 2022

I think now it looks really good, just one question about source PVC storage class.

ping - I think this is pretty harmless and spares us from nil panics

@brybacki
Copy link
Contributor

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 19, 2022
@awels
Copy link
Member

awels commented Oct 19, 2022

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: awels

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 19, 2022
@kubevirt-bot kubevirt-bot merged commit 4f0fa1f into kubevirt:main Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants