ignore if pv is marked as deleted
@@ -150,10 +150,6 @@ func (r *KalmPVReconciler) reconcilePV(pvName string) error {
if err != nil {
if errors.IsNotFound(err) {
// pvc not exist
- if pv.Labels[KalmLabelManaged] != "true" {
- return nil
- }
-
return r.reconcileOrphanPV(&pv)
} else {
return err
@@ -260,8 +256,15 @@ func (r *KalmPVReconciler) reconcileOrphanPVs(kalmPVList corev1.PersistentVolume
}
func (r *KalmPVReconciler) reconcileOrphanPV(orphanPV *corev1.PersistentVolume) error {
+ if orphanPV.Labels[KalmLabelManaged] != "true" ||
+ orphanPV.Labels[KalmLabelCleanIfPVCGone] != "" {
+ return nil
+ }
+
pvcName := fmt.Sprintf("pvc-orphan-%s", orphanPV.Name)
+ r.Log.Info("reconcileOrphanPV", "pvcName", pvcName)
+
expectedPVC := corev1.PersistentVolumeClaim{
ObjectMeta: metaV1.ObjectMeta{
Name: pvcName,
