From be5142fa365f3366b4febf178d2b152344e40fb8 Mon Sep 17 00:00:00 2001 From: Spground Date: Wed, 31 Jul 2024 14:14:43 +0800 Subject: [PATCH] Fix nil panic in cloneset validating webhook Signed-off-by: Spground --- pkg/webhook/cloneset/validating/validation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/webhook/cloneset/validating/validation.go b/pkg/webhook/cloneset/validating/validation.go index 2042064c41..d765746cb5 100644 --- a/pkg/webhook/cloneset/validating/validation.go +++ b/pkg/webhook/cloneset/validating/validation.go @@ -116,7 +116,7 @@ func (h *CloneSetCreateUpdateHandler) validateScaleStrategy(strategy, oldStrateg allErrs = append(allErrs, field.Invalid(fldPath.Child("podsToDelete"), podName, fmt.Sprintf("find pod %s failed: %v", podName, err))) } else if pod.DeletionTimestamp != nil { allErrs = append(allErrs, field.Invalid(fldPath.Child("podsToDelete"), podName, fmt.Sprintf("find pod %s already terminating", podName))) - } else if owner := metav1.GetControllerOf(pod); owner.UID != metadata.UID { + } else if owner := metav1.GetControllerOf(pod); owner == nil || owner.UID != metadata.UID { allErrs = append(allErrs, field.Invalid(fldPath.Child("podsToDelete"), podName, fmt.Sprintf("find pod %s owner is not this CloneSet", podName))) } }