-
Notifications
You must be signed in to change notification settings - Fork 267
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
Conversation
/test pull-containerized-data-importer-e2e-ceph |
3 similar comments
/test pull-containerized-data-importer-e2e-ceph |
/test pull-containerized-data-importer-e2e-ceph |
/test pull-containerized-data-importer-e2e-ceph |
0b2c44f
to
d182ecb
Compare
/test pull-containerized-data-importer-e2e-ceph |
d5901e9
to
d385e1c
Compare
3b08e10
to
e637a2b
Compare
/test all |
2 similar comments
/test all |
/test all |
/retest |
e637a2b
to
5388c83
Compare
if err != nil { | ||
return reconcile.Result{}, err | ||
} | ||
if storageClass == nil { |
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.
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?
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.
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 { |
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.
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?
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.
Also, maybe we should look into the selectCloneStrategy
and revise what is returned in case there is no StorageClass.
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.
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
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.
@brybacki Should be strictly about avoiding nils now. let me know what you think
5388c83
to
a7a48ee
Compare
a7a48ee
to
0c1d2fd
Compare
return reconcile.Result{}, err | ||
} | ||
if storageClass == nil { | ||
log.Info("Could not find a default storage class in the cluster") |
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.
It might be better to remove the word "default" and add the SC name
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.
yep, changed it to adjust the event message according to if we have the sc name or not
Expect(err).To(Not(HaveOccurred())) | ||
Expect(result).To(Not(BeNil())) |
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.
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}}) |
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.
Use dv.Name and dv.Namespace here
pkg/monitoring/BUILD.bazel
Outdated
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"], | ||
) |
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.
Are you sure this is needed?
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.
yeah but it already got added here #2226
one of the make targets re-adds this, not sure which one
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.
Rebased and this is now gone from my PR
0c1d2fd
to
80fcaeb
Compare
/test pull-cdi-apidocs |
Does this still need to get in or did we solve it some other way? |
This NPE is still possible afaik |
80fcaeb
to
5611cf8
Compare
5611cf8
to
edcc165
Compare
/retest |
edcc165
to
bd6012e
Compare
bd6012e
to
49eef45
Compare
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>
49eef45
to
1ad4cea
Compare
@@ -772,6 +772,7 @@ func (r *KubernetesReporter) Dump(kubeCli *kubernetes.Clientset, cdiClient *cdiC | |||
return | |||
} | |||
|
|||
r.logCSIDrivers(kubeCli) |
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.
👍
@@ -1886,6 +1897,9 @@ func (r *DatavolumeReconciler) validateAdvancedCloneSizeCompatible( | |||
sourcePvc *corev1.PersistentVolumeClaim, | |||
targetStorageSpec *corev1.PersistentVolumeClaimSpec) (bool, error) { | |||
srcStorageClass := &storagev1.StorageClass{} | |||
if sourcePvc.Spec.StorageClassName == nil { |
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.
is StorageClassName required for advancedClone to work (CSI and Snapshot)
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.
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
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.
Storage class is only optional for manually created PVs
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 |
/lgtm |
/approve |
[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 |
Signed-off-by: Alex Kalenyuk akalenyu@redhat.com
What this PR does / why we need it:
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: