Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions cluster-autoscaler/config/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package flags
import (
"flag"
"fmt"
"math"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -262,9 +263,20 @@ func createAutoscalingOptions() config.AutoscalingOptions {
if err != nil {
klog.Fatalf("Failed to parse flags: %v", err)
}
maxGiB := int64(math.MaxInt64 / units.GiB)
// Convert memory limits to bytes.
minMemoryTotal = minMemoryTotal * units.GiB
maxMemoryTotal = maxMemoryTotal * units.GiB
if minMemoryTotal > maxGiB {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to see some UTs for these overflow conditions

klog.Warning("Min memory limit overflowed, defaulting to 0")
minMemoryTotal = 0
} else {
minMemoryTotal = minMemoryTotal * units.GiB
}
if maxMemoryTotal > maxGiB {
klog.Warning("Max memory limit overflowed, defaulting to MaxInt64")
maxMemoryTotal = math.MaxInt64
} else {
maxMemoryTotal = maxMemoryTotal * units.GiB
}

parsedGpuTotal, err := parseMultipleGpuLimits(*gpuTotal)
if err != nil {
Expand Down