@@ -168,7 +168,16 @@ func (ctrl *csiSnapshotSideCarController) contentWorker() {
168
168
// been add/update/sync
169
169
if err == nil {
170
170
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 )
172
181
}
173
182
return false
174
183
}
@@ -230,15 +239,15 @@ func (ctrl *csiSnapshotSideCarController) isDriverMatch(content *crdv1.VolumeSna
230
239
231
240
// updateContent runs in worker thread and handles "content added",
232
241
// "content updated" and "periodic sync" events.
233
- func (ctrl * csiSnapshotSideCarController ) updateContentInCacheStore (content * crdv1.VolumeSnapshotContent ) {
242
+ func (ctrl * csiSnapshotSideCarController ) updateContentInCacheStore (content * crdv1.VolumeSnapshotContent ) error {
234
243
// Store the new content version in the cache and do not process it if this is
235
244
// an old version.
236
245
new , err := ctrl .storeContentUpdate (content )
237
246
if err != nil {
238
247
klog .Errorf ("%v" , err )
239
248
}
240
249
if ! new {
241
- return
250
+ return nil
242
251
}
243
252
err = ctrl .syncContent (content )
244
253
if err != nil {
@@ -249,7 +258,9 @@ func (ctrl *csiSnapshotSideCarController) updateContentInCacheStore(content *crd
249
258
} else {
250
259
klog .Errorf ("could not sync content %q: %+v" , content .Name , err )
251
260
}
261
+ return err
252
262
}
263
+ return nil
253
264
}
254
265
255
266
// deleteContent runs in worker thread and handles "content deleted" event.
0 commit comments