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.
This commit is contained in:
ravisantoshgudimetla 2021-05-10 13:51:19 -04:00
parent f94e8ba908
commit ceeb05a3d7

View File

@ -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)
}