Skip to content

Commit 67b5fcb

Browse files
committed
Add requeue in sidecar
1 parent d5804d5 commit 67b5fcb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pkg/sidecar-controller/snapshot_controller_base.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,16 @@ func (ctrl *csiSnapshotSideCarController) contentWorker() {
168168
// been add/update/sync
169169
if err == nil {
170170
if ctrl.isDriverMatch(content) {
171-
ctrl.updateContentInCacheStore(content)
171+
err = ctrl.updateContentInCacheStore(content)
172+
}
173+
if err != nil {
174+
// If error occurs we add this item back to the queue
175+
ctrl.contentQueue.AddRateLimited(keyObj)
176+
} else {
177+
// If no error occurs we Forget this item so it does not
178+
// get queued again until another change happens
179+
klog.V(4).Infof("Forget snapshotContent %q so it does not get queued again until another change happens", key)
180+
ctrl.contentQueue.Forget(keyObj)
172181
}
173182
return false
174183
}
@@ -230,15 +239,15 @@ func (ctrl *csiSnapshotSideCarController) isDriverMatch(content *crdv1.VolumeSna
230239

231240
// updateContent runs in worker thread and handles "content added",
232241
// "content updated" and "periodic sync" events.
233-
func (ctrl *csiSnapshotSideCarController) updateContentInCacheStore(content *crdv1.VolumeSnapshotContent) {
242+
func (ctrl *csiSnapshotSideCarController) updateContentInCacheStore(content *crdv1.VolumeSnapshotContent) error {
234243
// Store the new content version in the cache and do not process it if this is
235244
// an old version.
236245
new, err := ctrl.storeContentUpdate(content)
237246
if err != nil {
238247
klog.Errorf("%v", err)
239248
}
240249
if !new {
241-
return
250+
return nil
242251
}
243252
err = ctrl.syncContent(content)
244253
if err != nil {
@@ -249,7 +258,9 @@ func (ctrl *csiSnapshotSideCarController) updateContentInCacheStore(content *crd
249258
} else {
250259
klog.Errorf("could not sync content %q: %+v", content.Name, err)
251260
}
261+
return err
252262
}
263+
return nil
253264
}
254265

255266
// deleteContent runs in worker thread and handles "content deleted" event.

0 commit comments

Comments
 (0)