-
Notifications
You must be signed in to change notification settings - Fork 377
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
Fix error propagation in checkandAddSnapshotFinalizers and add tests #263
Fix error propagation in checkandAddSnapshotFinalizers and add tests #263
Conversation
@@ -665,26 +671,6 @@ func (ctrl *csiSnapshotCommonController) updateSnapshotErrorStatusWithEvent(snap | |||
return nil | |||
} | |||
|
|||
// isSnapshotConentBeingUsed checks if snapshot content is bound to 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.
this isn't used anywhere
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.
+1
/assign @xing-yang |
33419b0
to
15ac765
Compare
ctrl.checkandAddSnapshotFinalizers(snapshot) | ||
if err := ctrl.checkandAddSnapshotFinalizers(snapshot); err != nil { | ||
klog.Errorf("error check and add Snapshot finalizers for snapshot [%s]: %v", snapshot.Name, errFinalizer) | ||
ctrl.eventRecorder.Event(snapshot, v1.EventTypeWarning, "SnapshotCheckandUpdateFailed", fmt.Sprintf("Failed to check and update snapshot: %s", err.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.
I used this warning name from a test that used to test this behavior (before the controller split).
@@ -130,159 +130,44 @@ var snapshotClasses = []*crdv1.VolumeSnapshotClass{ | |||
func TestDeleteSync(t *testing.T) { | |||
tests := []controllerTest{ | |||
{ | |||
name: "1-1 - content with empty snapshot class is deleted if it is bound to a non-exist snapshot and also has a snapshot uid specified", |
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.
Many of these tests are no longer required in this package, or are duplicates of the new ones I wrote below (3-1, 3-2, etc)
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.
some nits otherwise LGTM. thanks
@@ -301,7 +305,9 @@ func (ctrl *csiSnapshotCommonController) checkandAddSnapshotFinalizers(snapshot | |||
if addSourceFinalizer || addBoundFinalizer { | |||
// Snapshot is not being deleted -> it should have the finalizer. | |||
klog.V(5).Infof("checkandAddSnapshotFinalizers: Add Finalizer for VolumeSnapshot[%s]", utils.SnapshotKey(snapshot)) | |||
ctrl.addSnapshotFinalizer(snapshot, addSourceFinalizer, addBoundFinalizer) | |||
if err := ctrl.addSnapshotFinalizer(snapshot, addSourceFinalizer, addBoundFinalizer); err != 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.
nit: how about simply? "return ctrl.addSnapshot....."
@@ -665,26 +671,6 @@ func (ctrl *csiSnapshotCommonController) updateSnapshotErrorStatusWithEvent(snap | |||
return nil | |||
} | |||
|
|||
// isSnapshotConentBeingUsed checks if snapshot content is bound to 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.
+1
@@ -1494,3 +1501,5 @@ func emptyDataSecretAnnotations() map[string]string { | |||
utils.AnnDeletionSecretRefNamespace: "default", | |||
} | |||
} | |||
|
|||
func toStrPointer(str string) *string { return &str } |
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.
where is this function used? seems not in this PR
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.
Ah yeah, I was using it for a test originally but removed it's usage. Will remove this
65ae98f
to
a5c9c35
Compare
Addressed your suggestions @yuxiangqian. Thanks! |
/lgtm /approve |
/assign @yuxiangqian |
@ggriffiths please squash the commits. thanks |
Signed-off-by: Grant Griffiths <[email protected]>
a5c9c35
to
9830b6e
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ggriffiths, yuxiangqian 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 |
/lgtm |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Adds more tests, and fixes a few bugs I found.
Which issue(s) this PR fixes:
Fixes #196
Special notes for your reviewer:
Does this PR introduce a user-facing change?: