From 59bd99edb79dd925b97bd4a1644df819e38ef96b Mon Sep 17 00:00:00 2001 From: Wei-Xiang Sun Date: Fri, 17 Jun 2022 19:03:08 +0800 Subject: [PATCH] fix panic cased by sts auto delete pvc (#999) Signed-off-by: mingzhou.swx Co-authored-by: mingzhou.swx Signed-off-by: Liu Zhenwei --- pkg/controller/statefulset/stateful_set_utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/controller/statefulset/stateful_set_utils.go b/pkg/controller/statefulset/stateful_set_utils.go index 9b7c5ec0e5..fd016f5c60 100644 --- a/pkg/controller/statefulset/stateful_set_utils.go +++ b/pkg/controller/statefulset/stateful_set_utils.go @@ -140,7 +140,7 @@ func getPersistentVolumeClaimRetentionPolicy(set *appsv1beta1.StatefulSet) appsv // claimOwnerMatchesSetAndPod returns false if the ownerRefs of the claim are not set consistently with the // PVC deletion policy for the StatefulSet. func claimOwnerMatchesSetAndPod(claim *v1.PersistentVolumeClaim, set *appsv1beta1.StatefulSet, pod *v1.Pod) bool { - policy := set.Spec.PersistentVolumeClaimRetentionPolicy + policy := getPersistentVolumeClaimRetentionPolicy(set) const retain = appsv1beta1.RetainPersistentVolumeClaimRetentionPolicyType const delete = appsv1beta1.DeletePersistentVolumeClaimRetentionPolicyType switch { @@ -202,7 +202,7 @@ func updateClaimOwnerRefForSetAndPod(claim *v1.PersistentVolumeClaim, set *appsv updateMeta(&podMeta, "Pod") setMeta := set.TypeMeta updateMeta(&setMeta, "StatefulSet") - policy := set.Spec.PersistentVolumeClaimRetentionPolicy + policy := getPersistentVolumeClaimRetentionPolicy(set) const retain = appsv1beta1.RetainPersistentVolumeClaimRetentionPolicyType const delete = appsv1beta1.DeletePersistentVolumeClaimRetentionPolicyType switch {