Fix err shadow in updateSnapshotStatus and add retry delay

Signed-off-by: Grant Griffiths <grant@portworx.com>
This commit is contained in:
Grant Griffiths
2019-12-20 09:39:11 -08:00
parent 53469c2196
commit b5f2165795

View File

@@ -344,6 +344,7 @@ func (ctrl *csiSnapshotCommonController) syncUnreadySnapshot(snapshot *crdv1.Vol
break break
} }
klog.V(4).Infof("failed to update snapshot %s status: %v", utils.SnapshotKey(snapshot), err) klog.V(4).Infof("failed to update snapshot %s status: %v", utils.SnapshotKey(snapshot), err)
time.Sleep(ctrl.createSnapshotContentInterval)
} }
if err != nil { if err != nil {
@@ -406,6 +407,7 @@ func (ctrl *csiSnapshotCommonController) syncUnreadySnapshot(snapshot *crdv1.Vol
break break
} }
klog.V(4).Infof("failed to update snapshot %s status: %v", utils.SnapshotKey(snapshot), err) klog.V(4).Infof("failed to update snapshot %s status: %v", utils.SnapshotKey(snapshot), err)
time.Sleep(ctrl.createSnapshotContentInterval)
} }
if err != nil { if err != nil {
@@ -865,16 +867,17 @@ func (ctrl *csiSnapshotCommonController) bindandUpdateVolumeSnapshot(snapshotCon
// Copy the snapshot object before updating it // Copy the snapshot object before updating it
snapshotCopy := snapshotObj.DeepCopy() snapshotCopy := snapshotObj.DeepCopy()
// update snapshot status // update snapshot status
var updateSnapshot *crdv1.VolumeSnapshot
for i := 0; i < ctrl.createSnapshotContentRetryCount; i++ { for i := 0; i < ctrl.createSnapshotContentRetryCount; i++ {
klog.V(5).Infof("bindandUpdateVolumeSnapshot [%s]: trying to update snapshot status", utils.SnapshotKey(snapshotCopy)) klog.V(5).Infof("bindandUpdateVolumeSnapshot [%s]: trying to update snapshot status", utils.SnapshotKey(snapshotCopy))
updateSnapshot, err := ctrl.updateSnapshotStatus(snapshotCopy, snapshotContent) updateSnapshot, err = ctrl.updateSnapshotStatus(snapshotCopy, snapshotContent)
if err == nil { if err == nil {
snapshotCopy = updateSnapshot snapshotCopy = updateSnapshot
break break
} }
klog.V(4).Infof("failed to update snapshot %s status: %v", utils.SnapshotKey(snapshot), err) klog.V(4).Infof("failed to update snapshot %s status: %v", utils.SnapshotKey(snapshot), err)
time.Sleep(ctrl.createSnapshotContentInterval)
} }
if err != nil { if err != nil {