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).
This commit is contained in:
Timo Reimann
2021-02-07 21:57:14 +01:00
committed by Timo Reimann
parent cbe212e899
commit b31a29fd83

View File

@@ -300,13 +300,12 @@ func (ctrl *csiSnapshotSideCarController) createSnapshotWrapper(content *crdv1.V
// storage system has responded with an error
klog.Infof("createSnapshotWrapper: CreateSnapshot for content %s returned error: %v", content.Name, err)
if isCSIFinalError(err) {
err = ctrl.removeAnnVolumeSnapshotBeingCreated(content)
if err != nil {
return nil, fmt.Errorf("failed to remove VolumeSnapshotBeingCreated annotation from the content %s: %q", content.Name, err)
if err := ctrl.removeAnnVolumeSnapshotBeingCreated(content); err != nil {
return nil, fmt.Errorf("failed to remove VolumeSnapshotBeingCreated annotation from the content %s: %s", content.Name, err)
}
}
return nil, fmt.Errorf("failed to take snapshot of the volume, %s: %q", *content.Spec.Source.VolumeHandle, err)
return nil, fmt.Errorf("failed to take snapshot of the volume %s: %q", *content.Spec.Source.VolumeHandle, err)
}
klog.V(5).Infof("Created snapshot: driver %s, snapshotId %s, creationTime %v, size %d, readyToUse %t", driverName, snapshotID, creationTime, size, readyToUse)