@@ -260,11 +260,27 @@ func (ctrl *csiSnapshotSideCarController) syncContentByKey(key string) (requeue
260
260
// been add/update/sync
261
261
if err == nil {
262
262
if ctrl .isDriverMatch (content ) {
263
- requeue , err = ctrl .updateContentInInformerCache (content )
264
- }
265
- if err != nil {
266
- // If error occurs we add this item back to the queue
267
- return true , err
263
+ // Store the new content version in the cache and do not process it if this is
264
+ // an old version.
265
+ new , err := ctrl .storeContentUpdate (content )
266
+ if err != nil {
267
+ klog .Errorf ("%v" , err )
268
+ }
269
+ if ! new {
270
+ return false , nil
271
+ }
272
+ requeue , err = ctrl .syncContent (content )
273
+ if err != nil {
274
+ if errors .IsConflict (err ) {
275
+ // Version conflict error happens quite often and the controller
276
+ // recovers from it easily.
277
+ klog .V (3 ).Infof ("could not sync content %q: %+v" , content .Name , err )
278
+ } else {
279
+ klog .Errorf ("could not sync content %q: %+v" , content .Name , err )
280
+ }
281
+ // If error occurs we add this item back to the queue
282
+ return true , err
283
+ }
268
284
}
269
285
return requeue , nil
270
286
}
@@ -339,32 +355,6 @@ func (ctrl *csiSnapshotSideCarController) isDriverMatch(object interface{}) bool
339
355
return false
340
356
}
341
357
342
- // updateContentInInformerCache runs in worker thread and handles "content added",
343
- // "content updated" and "periodic sync" events.
344
- func (ctrl * csiSnapshotSideCarController ) updateContentInInformerCache (content * crdv1.VolumeSnapshotContent ) (requeue bool , err error ) {
345
- // Store the new content version in the cache and do not process it if this is
346
- // an old version.
347
- new , err := ctrl .storeContentUpdate (content )
348
- if err != nil {
349
- klog .Errorf ("%v" , err )
350
- }
351
- if ! new {
352
- return false , nil
353
- }
354
- requeue , err = ctrl .syncContent (content )
355
- if err != nil {
356
- if errors .IsConflict (err ) {
357
- // Version conflict error happens quite often and the controller
358
- // recovers from it easily.
359
- klog .V (3 ).Infof ("could not sync content %q: %+v" , content .Name , err )
360
- } else {
361
- klog .Errorf ("could not sync content %q: %+v" , content .Name , err )
362
- }
363
- return requeue , err
364
- }
365
- return requeue , nil
366
- }
367
-
368
358
// deleteContent runs in worker thread and handles "content deleted" event.
369
359
func (ctrl * csiSnapshotSideCarController ) deleteContentInCacheStore (content * crdv1.VolumeSnapshotContent ) {
370
360
_ = ctrl .contentStore .Delete (content )
0 commit comments