Skip to content

Commit 4d71656

Browse files
timoreimannialidzhikov
authored andcommitted
Retain CreateSnapshot error
The error returned from CreateSnapshot was overwritten by the call to removeAnnVolumeSnapshotBeingCreated. Retain the error through variable shadowing so that it can be propagated and reported upwards the call stack. We also improve the error line by dropping an unnecessary comma and dequoting the error string (since we already employ a colon separator).
1 parent 3906416 commit 4d71656

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pkg/sidecar-controller/snapshot_controller.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,12 @@ func (ctrl *csiSnapshotSideCarController) createSnapshotWrapper(content *crdv1.V
300300
// storage system has responded with an error
301301
klog.Infof("createSnapshotWrapper: CreateSnapshot for content %s returned error: %v", content.Name, err)
302302
if isCSIFinalError(err) {
303-
err = ctrl.removeAnnVolumeSnapshotBeingCreated(content)
304-
if err != nil {
305-
return nil, fmt.Errorf("failed to remove VolumeSnapshotBeingCreated annotation from the content %s: %q", content.Name, err)
303+
if err := ctrl.removeAnnVolumeSnapshotBeingCreated(content); err != nil {
304+
return nil, fmt.Errorf("failed to remove VolumeSnapshotBeingCreated annotation from the content %s: %s", content.Name, err)
306305
}
307306
}
308307

309-
return nil, fmt.Errorf("failed to take snapshot of the volume, %s: %q", *content.Spec.Source.VolumeHandle, err)
308+
return nil, fmt.Errorf("failed to take snapshot of the volume %s: %q", *content.Spec.Source.VolumeHandle, err)
310309
}
311310

312311
klog.V(5).Infof("Created snapshot: driver %s, snapshotId %s, creationTime %v, size %d, readyToUse %t", driverName, snapshotID, creationTime, size, readyToUse)

0 commit comments

Comments
 (0)