@@ -67,22 +67,22 @@ func (ctrl *csiSnapshotSideCarController) syncContent(content *crdv1.VolumeSnaps
6767 // Note that the deletion snapshot operation will update content SnapshotHandle
6868 // to nil upon a successful deletion. At this
6969 // point, the finalizer on content should NOT be removed to avoid leaking.
70- err := ctrl .deleteCSISnapshot (content )
70+ var err error
71+ content , err = ctrl .deleteCSISnapshot (content )
7172 if err != nil {
7273 return true , err
7374 }
74- return false , nil
75+ // Continue removing the finalizer
7576 }
76- // otherwise, either the snapshot has been deleted from the underlying
77- // storage system, or it belongs to a volumegroupsnapshot, or the deletion policy is Retain,
77+ // the snapshot has been deleted from the underlying storage system, or
78+ // it belongs to a volumegroupsnapshot, or the deletion policy is Retain,
7879 // remove the finalizer if there is one so that API server could delete
7980 // the object if there is no other finalizer.
8081 err := ctrl .removeContentFinalizer (content )
8182 if err != nil {
8283 return true , err
8384 }
8485 return false , nil
85-
8686 }
8787
8888 // Create snapshot calling the CSI driver only if it is a dynamic
@@ -109,7 +109,7 @@ func (ctrl *csiSnapshotSideCarController) syncContent(content *crdv1.VolumeSnaps
109109}
110110
111111// deleteCSISnapshot starts delete action.
112- func (ctrl * csiSnapshotSideCarController ) deleteCSISnapshot (content * crdv1.VolumeSnapshotContent ) error {
112+ func (ctrl * csiSnapshotSideCarController ) deleteCSISnapshot (content * crdv1.VolumeSnapshotContent ) ( * crdv1. VolumeSnapshotContent , error ) {
113113 klog .V (5 ).Infof ("Deleting snapshot for content: %s" , content .Name )
114114 return ctrl .deleteCSISnapshotOperation (content )
115115}
@@ -406,31 +406,29 @@ func (ctrl *csiSnapshotSideCarController) createSnapshotWrapper(content *crdv1.V
406406}
407407
408408// Delete a snapshot: Ask the backend to remove the snapshot device
409- func (ctrl * csiSnapshotSideCarController ) deleteCSISnapshotOperation (content * crdv1.VolumeSnapshotContent ) error {
409+ func (ctrl * csiSnapshotSideCarController ) deleteCSISnapshotOperation (content * crdv1.VolumeSnapshotContent ) ( * crdv1. VolumeSnapshotContent , error ) {
410410 klog .V (5 ).Infof ("deleteCSISnapshotOperation [%s] started" , content .Name )
411411
412412 snapshotterCredentials , err := ctrl .GetCredentialsFromAnnotation (content )
413413 if err != nil {
414414 ctrl .eventRecorder .Event (content , v1 .EventTypeWarning , "SnapshotDeleteError" , "Failed to get snapshot credentials" )
415- return fmt .Errorf ("failed to get input parameters to delete snapshot for content %s: %q" , content .Name , err )
415+ return content , fmt .Errorf ("failed to get input parameters to delete snapshot for content %s: %q" , content .Name , err )
416416 }
417417
418418 err = ctrl .handler .DeleteSnapshot (content , snapshotterCredentials )
419419 if err != nil {
420420 ctrl .eventRecorder .Event (content , v1 .EventTypeWarning , "SnapshotDeleteError" , "Failed to delete snapshot" )
421- return fmt .Errorf ("failed to delete snapshot %#v, err: %v" , content .Name , err )
421+ return content , fmt .Errorf ("failed to delete snapshot %#v, err: %v" , content .Name , err )
422422 }
423423 // the snapshot has been deleted from the underlying storage system, update
424424 // content status to remove snapshot handle etc.
425+ // This triggers a re-sync of the content object, which will continue cleaning the object (e.g. finalizers)
425426 newContent , err := ctrl .clearVolumeContentStatus (content .Name )
426427 if err != nil {
427428 ctrl .eventRecorder .Event (content , v1 .EventTypeWarning , "SnapshotDeleteError" , "Failed to clear content status" )
428- return err
429+ return content , err
429430 }
430- // trigger syncContent
431- // TODO: just enqueue the content object instead of calling syncContent directly
432- ctrl .updateContentInInformerCache (newContent )
433- return nil
431+ return newContent , nil
434432}
435433
436434// clearVolumeContentStatus resets all fields to nil related to a snapshot in
0 commit comments