Skip to content

Commit a1192b6

Browse files
authored
Merge pull request #232 from xing-yang/pvc_finalizer
Remove PVC finalizer when no longer in use
2 parents 2589c16 + 824ce7f commit a1192b6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pkg/common-controller/snapshot_controller.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ func (ctrl *csiSnapshotCommonController) syncContent(content *crdv1.VolumeSnapsh
156156
func (ctrl *csiSnapshotCommonController) syncSnapshot(snapshot *crdv1.VolumeSnapshot) error {
157157
klog.V(5).Infof("synchronizing VolumeSnapshot[%s]: %s", utils.SnapshotKey(snapshot), utils.GetSnapshotStatusForLogging(snapshot))
158158

159+
klog.V(5).Infof("syncSnapshot [%s]: check if we should remove finalizer on snapshot PVC source and remove it if we can", utils.SnapshotKey(snapshot))
160+
161+
// Check if we should remove finalizer on PVC and remove it if we can.
162+
errFinalizer := ctrl.checkandRemovePVCFinalizer(snapshot)
163+
if errFinalizer != nil {
164+
klog.Errorf("error check and remove PVC finalizer for snapshot [%s]: %v", snapshot.Name, errFinalizer)
165+
// Log an event and keep the original error from syncUnready/ReadySnapshot
166+
ctrl.eventRecorder.Event(snapshot, v1.EventTypeWarning, "ErrorPVCFinalizer", "Error check and remove PVC Finalizer for VolumeSnapshot")
167+
}
168+
159169
if snapshot.ObjectMeta.DeletionTimestamp != nil {
160170
err := ctrl.processSnapshotWithDeletionTimestamp(snapshot)
161171
if err != nil {
@@ -206,7 +216,6 @@ func (ctrl *csiSnapshotCommonController) checkContentAndBoundStatus(snapshot *cr
206216
// processSnapshotWithDeletionTimestamp processes finalizers and deletes the content when appropriate. It has the following steps:
207217
// 1. Call a helper function checkContentAndBoundStatus() to check content and bound status.
208218
// 2. Call checkandRemoveSnapshotFinalizersAndCheckandDeleteContent() with information obtained from step 1. This function name is very long but the name suggests what it does. It determines whether to remove finalizers on snapshot and whether to delete content.
209-
// 3. Call checkandRemovePVCFinalizer() to determine whether to remove the finalizer on PVC.
210219
func (ctrl *csiSnapshotCommonController) processSnapshotWithDeletionTimestamp(snapshot *crdv1.VolumeSnapshot) error {
211220
klog.V(5).Infof("processSnapshotWithDeletionTimestamp VolumeSnapshot[%s]: %s", utils.SnapshotKey(snapshot), utils.GetSnapshotStatusForLogging(snapshot))
212221

@@ -222,15 +231,6 @@ func (ctrl *csiSnapshotCommonController) processSnapshotWithDeletionTimestamp(sn
222231
return err
223232
}
224233

225-
klog.V(5).Infof("processSnapshotWithDeletionTimestamp[%s]: check if we should remove finalizer on snapshot source and remove it if we can", utils.SnapshotKey(snapshot))
226-
227-
// Check if we should remove finalizer on PVC and remove it if we can.
228-
errFinalizer := ctrl.checkandRemovePVCFinalizer(snapshot)
229-
if errFinalizer != nil {
230-
klog.Errorf("error check and remove PVC finalizer for snapshot [%s]: %v", snapshot.Name, errFinalizer)
231-
// Log an event and keep the original error from syncUnready/ReadySnapshot
232-
ctrl.eventRecorder.Event(snapshot, v1.EventTypeWarning, "ErrorPVCFinalizer", "Error check and remove PVC Finalizer for VolumeSnapshot")
233-
}
234234
return nil
235235
}
236236

0 commit comments

Comments
 (0)