Skip to content

Commit 2295e6a

Browse files
committed
Add error status check in createSnapshotWrapper
1 parent 9f382ac commit 2295e6a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/sidecar-controller/snapshot_controller.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,6 @@ func (ctrl *csiSnapshotSideCarController) createSnapshot(content *crdv1.VolumeSn
133133
klog.V(5).Infof("createSnapshot for content [%s]: started", content.Name)
134134
opName := fmt.Sprintf("create-%s", content.Name)
135135
ctrl.scheduleOperation(opName, func() error {
136-
// content.Status will be created for the first time after a snapshot
137-
// is created by the CSI driver. If content.Status is not nil,
138-
// we should update content status without creating snapshot again.
139-
if content.Status != nil && content.Status.Error != nil && content.Status.Error.Message != nil && !isControllerUpdateFailError(content.Status.Error) {
140-
klog.V(4).Infof("error is already set in snapshot, do not retry to create: %s", *content.Status.Error.Message)
141-
return nil
142-
}
143136
contentObj, err := ctrl.createSnapshotWrapper(content)
144137
if err != nil {
145138
ctrl.updateContentErrorStatusWithEvent(content, v1.EventTypeWarning, "SnapshotCreationFailed", fmt.Sprintf("Failed to create snapshot: %v", err))
@@ -311,6 +304,14 @@ func (ctrl *csiSnapshotSideCarController) checkandUpdateContentStatusOperation(c
311304
func (ctrl *csiSnapshotSideCarController) createSnapshotWrapper(content *crdv1.VolumeSnapshotContent) (*crdv1.VolumeSnapshotContent, error) {
312305
klog.Infof("createSnapshotWrapper: Creating snapshot for content %s through the plugin ...", content.Name)
313306

307+
// content.Status will be created for the first time after a snapshot
308+
// is created by the CSI driver. If content.Status is not nil,
309+
// we should update content status without creating snapshot again.
310+
if content.Status != nil && content.Status.Error != nil && content.Status.Error.Message != nil && !isControllerUpdateFailError(content.Status.Error) {
311+
klog.V(4).Infof("error is already set in snapshot, do not retry to create: %s", *content.Status.Error.Message)
312+
return content, nil
313+
}
314+
314315
class, snapshotterCredentials, err := ctrl.getCSISnapshotInput(content)
315316
if err != nil {
316317
return nil, fmt.Errorf("failed to get input parameters to create snapshot for content %s: %q", content.Name, err)
@@ -624,7 +625,6 @@ func (ctrl *csiSnapshotSideCarController) setAnnVolumeSnapshotBeingCreated(conte
624625
_, err = ctrl.storeContentUpdate(content)
625626
if err != nil {
626627
klog.V(4).Infof("setAnnVolumeSnapshotBeingCreated for content [%s]: cannot update internal cache %v", content.Name, err)
627-
return err
628628
}
629629
klog.V(5).Infof("setAnnVolumeSnapshotBeingCreated: volume snapshot content %+v", content)
630630

0 commit comments

Comments
 (0)