Skip to content

Commit 3c5c62f

Browse files
Do not reconcile for updating volume health annotation on TKG PVC if found deleted, even if TKG PV retained, (#3414)
for given supervisor PVC
1 parent b404f28 commit 3c5c62f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/syncer/volume_health_reconciler.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,20 @@ func (rc *volumeHealthReconciler) tkgUpdatePV(oldObj, newObj interface{}) {
222222
if newPv.Spec.CSI != nil && newPv.Spec.CSI.Driver == csitypes.Name &&
223223
oldPv.Status.Phase != v1.VolumeBound && newPv.Status.Phase == v1.VolumeBound {
224224
// Add to volumeHandleToPVs.
225+
log.Infof("tkgUpdatePV: Add PV %s from TKGPVList to update", newPv.Name)
225226
rc.volumeHandleToPVs.add(newPv.Spec.CSI.VolumeHandle, newPv.Name)
226227

227228
// Add SVC PVC to work queue to add volume health annotation to statically
228229
// provisioned volumes.
229230
objKey := rc.supervisorNamespace + "/" + newPv.Spec.CSI.VolumeHandle
230231
log.Infof("tkgUpdatePV: add %s to claim queue", objKey)
231232
rc.svcClaimQueue.Add(objKey)
233+
} else if (newPv.Spec.CSI != nil) && (newPv.Spec.CSI.Driver == csitypes.Name) &&
234+
(newPv.Spec.PersistentVolumeReclaimPolicy == v1.PersistentVolumeReclaimRetain) &&
235+
(oldPv.Status.Phase == v1.VolumeBound) && (newPv.Status.Phase == v1.VolumeReleased) {
236+
// Remove from volumeHandleToPVs.
237+
log.Infof("tkgUpdatePV: Remove PV %s from TKGPVList to update", newPv.Name)
238+
rc.volumeHandleToPVs.remove(newPv.Spec.CSI.VolumeHandle, newPv.Name)
232239
}
233240
}
234241

@@ -355,7 +362,7 @@ func (rc *volumeHealthReconciler) syncPVC(key string) error {
355362
if tkgPVList == nil {
356363
// If no PV is found, the SV PVC may not be referenced within
357364
// this TKG. Do not requeue this request.
358-
log.Debugf("Tanzu Kubernetes Grid PV not found for Supervisor PVC %s/%s. Igonoring ...", namespace, name)
365+
log.Debugf("Tanzu Kubernetes Grid PV not found for Supervisor PVC %s/%s. Ignoring ...", namespace, name)
359366
return nil
360367
}
361368

0 commit comments

Comments
 (0)