Skip to content

Commit 17a3a4d

Browse files
committed
fix: should no change the reclaim policy of PV to Delete (#8980)
(cherry picked from commit b5f15e0)
1 parent a9d07bc commit 17a3a4d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

controllers/apps/component/transformer_component_workload.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,11 @@ func (r *componentWorkloadOps) updatePVCSize(pvcKey types.NamespacedName,
10431043
// if both pvc and pv not found, do nothing
10441044
return nil
10451045
}
1046-
if reflect.DeepEqual(pvc.Spec.Resources, newPVC.Spec.Resources) && pv.Spec.PersistentVolumeReclaimPolicy == corev1.PersistentVolumeReclaimRetain {
1046+
if reflect.DeepEqual(pvc.Spec.Resources, newPVC.Spec.Resources) &&
1047+
pv.Spec.PersistentVolumeReclaimPolicy == corev1.PersistentVolumeReclaimRetain &&
1048+
pv.Annotations != nil &&
1049+
len(pv.Annotations[constant.PVLastClaimPolicyAnnotationKey]) > 0 &&
1050+
pv.Annotations[constant.PVLastClaimPolicyAnnotationKey] != string(corev1.PersistentVolumeReclaimRetain) {
10471051
// this could happen if create pvc succeeded but last step failed
10481052
updatePVCByRecreateFromStep(pvRestorePolicyStep)
10491053
return nil

0 commit comments

Comments
 (0)