From ceeb05a3d75b87e627d96a976384b17b10d6c439 Mon Sep 17 00:00:00 2001 From: ravisantoshgudimetla Date: Mon, 10 May 2021 13:51:19 -0400 Subject: [PATCH] DaemonSet: Fix surgeCount function If the surge is not requested, we should return 0. We are returning an error now as r.MaxSurge is passed down as nil. This commit fixes the issue by setting the surgeCount to 0 if r.MaxSurge is nil. --- pkg/controller/daemon/util/daemonset_util.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/controller/daemon/util/daemonset_util.go b/pkg/controller/daemon/util/daemonset_util.go index f2b58237c20..acff170506c 100644 --- a/pkg/controller/daemon/util/daemonset_util.go +++ b/pkg/controller/daemon/util/daemonset_util.go @@ -144,6 +144,10 @@ func SurgeCount(ds *apps.DaemonSet, numberToSchedule int) (int, error) { if r == nil { return 0, nil } + // If surge is not requested, we should default to 0. + if r.MaxSurge == nil { + return 0, nil + } return intstrutil.GetScaledValueFromIntOrPercent(r.MaxSurge, numberToSchedule, true) }