-
Notifications
You must be signed in to change notification settings - Fork 382
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 panic when source PVC does not exist #381
Fix panic when source PVC does not exist #381
Conversation
checkAndUpdateSnapshotClass must always return a snapshot, even though it fails somewhere in ctrl.SetDefaultSnapshotClass. Add unit tests for that.
/retest |
@@ -317,6 +317,7 @@ func (ctrl *csiSnapshotCommonController) syncContentByKey(key string) error { | |||
|
|||
// checkAndUpdateSnapshotClass gets the VolumeSnapshotClass from VolumeSnapshot. If it is not set, | |||
// gets it from default VolumeSnapshotClass and sets it. | |||
// On error, it returns the original 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.
Can you change to the following?
On error, it must return the original snapshot, not nil, because the caller syncContentByKey needs to check snapshot's timestamp.
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.
Done
3bc4aea
to
73f72bd
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jsafrane, xing-yang 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 |
Cherry-pick kubernetes-csi#381. Fixed crash of snapshot-controller when source PVC of a snapshot to take does not exist.
checkAndUpdateSnapshotClass
must always return a snapshot, even though it fails somewhere inctrl.SetDefaultSnapshotClass
-syncSnapshotByKey
panics with nil return. I tried to fixsyncSnapshotByKey
to allow nil return, but the resulting code was just ugly.While the real fix is one-liner in snapshot_controller_base.go, the PR is bigger due to test refactoring -
testCall
must have an opportunity to return a "fatal" error, even though a "normal" error is expected./kind bug
Fixes: #380