From cd0f316eaaf4be68fa8609fda54ed38be98f8387 Mon Sep 17 00:00:00 2001 From: Wei-Xiang Sun Date: Fri, 22 Jul 2022 14:51:40 +0800 Subject: [PATCH] fix panic cased by sts predownload image (#1031) Signed-off-by: mingzhou.swx Co-authored-by: mingzhou.swx Signed-off-by: Liu Zhenwei --- pkg/controller/statefulset/statefulset_predownload_image.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/controller/statefulset/statefulset_predownload_image.go b/pkg/controller/statefulset/statefulset_predownload_image.go index ea94b052e9..8b98068c62 100644 --- a/pkg/controller/statefulset/statefulset_predownload_image.go +++ b/pkg/controller/statefulset/statefulset_predownload_image.go @@ -45,8 +45,9 @@ func (dss *defaultStatefulSetControl) createImagePullJobsForInPlaceUpdate(sts *a return nil } - // ignore if update type is ReCreate - if string(sts.Spec.UpdateStrategy.Type) == string(appsv1beta1.RecreatePodUpdateStrategyType) { + // ignore if update type is OnDelete or pod update policy is ReCreate + if string(sts.Spec.UpdateStrategy.Type) == string(apps.OnDeleteStatefulSetStrategyType) || sts.Spec.UpdateStrategy.RollingUpdate == nil || + string(sts.Spec.UpdateStrategy.RollingUpdate.PodUpdatePolicy) == string(appsv1beta1.RecreatePodUpdateStrategyType) { klog.V(4).Infof("Statefulset %s/%s skipped to create ImagePullJob for update type is %s", sts.Namespace, sts.Name, sts.Spec.UpdateStrategy.Type) return dss.patchControllerRevisionLabels(updateRevision, appsv1alpha1.ImagePreDownloadIgnoredKey, "true")