From 10017c2bdccc95268596aefdcbdc769bc5b2dc3c Mon Sep 17 00:00:00 2001 From: xing-yang Date: Wed, 18 Dec 2019 21:49:05 +0000 Subject: [PATCH] Add snapshot back to queue --- pkg/common-controller/snapshot_controller_base.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/common-controller/snapshot_controller_base.go b/pkg/common-controller/snapshot_controller_base.go index 66c73e8c..555f9958 100644 --- a/pkg/common-controller/snapshot_controller_base.go +++ b/pkg/common-controller/snapshot_controller_base.go @@ -207,9 +207,12 @@ func (ctrl *csiSnapshotCommonController) snapshotWorker() { newSnapshot, err := ctrl.checkAndUpdateSnapshotClass(snapshot) if err == nil { 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) { 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", // "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 // an old version. klog.V(5).Infof("updateSnapshot %q", utils.SnapshotKey(snapshot)) @@ -349,7 +352,7 @@ func (ctrl *csiSnapshotCommonController) updateSnapshot(snapshot *crdv1.VolumeSn klog.Errorf("%v", err) } if !newSnapshot { - return + return nil } err = ctrl.syncSnapshot(snapshot) 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) } else { 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",