Add snapshot back to queue

This commit is contained in:
xing-yang
2019-12-18 21:49:05 +00:00
parent 60c696c7c7
commit 10017c2bdc

View File

@@ -207,9 +207,12 @@ func (ctrl *csiSnapshotCommonController) snapshotWorker() {
newSnapshot, err := ctrl.checkAndUpdateSnapshotClass(snapshot) newSnapshot, err := ctrl.checkAndUpdateSnapshotClass(snapshot)
if err == nil { if err == nil {
klog.V(5).Infof("passed checkAndUpdateSnapshotClass for snapshot %q", key) klog.V(5).Infof("passed checkAndUpdateSnapshotClass for snapshot %q", key)
ctrl.updateSnapshot(newSnapshot) err = ctrl.updateSnapshot(newSnapshot)
}
if err != nil {
ctrl.snapshotQueue.AddRateLimited(key)
return false
} }
return false
} }
if err != nil && !errors.IsNotFound(err) { if err != nil && !errors.IsNotFound(err) {
klog.V(2).Infof("error getting snapshot %q from informer: %v", key, err) klog.V(2).Infof("error getting snapshot %q from informer: %v", key, err)
@@ -340,7 +343,7 @@ func (ctrl *csiSnapshotCommonController) checkAndUpdateSnapshotClass(snapshot *c
// updateSnapshot runs in worker thread and handles "snapshot added", // updateSnapshot runs in worker thread and handles "snapshot added",
// "snapshot updated" and "periodic sync" events. // "snapshot updated" and "periodic sync" events.
func (ctrl *csiSnapshotCommonController) updateSnapshot(snapshot *crdv1.VolumeSnapshot) { func (ctrl *csiSnapshotCommonController) updateSnapshot(snapshot *crdv1.VolumeSnapshot) error {
// Store the new snapshot version in the cache and do not process it if this is // Store the new snapshot version in the cache and do not process it if this is
// an old version. // an old version.
klog.V(5).Infof("updateSnapshot %q", utils.SnapshotKey(snapshot)) klog.V(5).Infof("updateSnapshot %q", utils.SnapshotKey(snapshot))
@@ -349,7 +352,7 @@ func (ctrl *csiSnapshotCommonController) updateSnapshot(snapshot *crdv1.VolumeSn
klog.Errorf("%v", err) klog.Errorf("%v", err)
} }
if !newSnapshot { if !newSnapshot {
return return nil
} }
err = ctrl.syncSnapshot(snapshot) err = ctrl.syncSnapshot(snapshot)
if err != nil { if err != nil {
@@ -359,8 +362,10 @@ func (ctrl *csiSnapshotCommonController) updateSnapshot(snapshot *crdv1.VolumeSn
klog.V(3).Infof("could not sync claim %q: %+v", utils.SnapshotKey(snapshot), err) klog.V(3).Infof("could not sync claim %q: %+v", utils.SnapshotKey(snapshot), err)
} else { } else {
klog.Errorf("could not sync volume %q: %+v", utils.SnapshotKey(snapshot), err) klog.Errorf("could not sync volume %q: %+v", utils.SnapshotKey(snapshot), err)
return err
} }
} }
return nil
} }
// updateContent runs in worker thread and handles "content added", // updateContent runs in worker thread and handles "content added",