Fix: don't cut node name if it's an ip

rare case, but it was not producing great results
regression tests will come for this
This commit is contained in:
Yoann La Cancellera
2023-10-05 13:29:42 +02:00
parent 94c89c2892
commit b0477bc37f

View File

@@ -3,6 +3,8 @@ package utils
import (
"fmt"
"strings"
"k8s.io/utils/net"
)
// Color is given its own type for safe function signatures
@@ -118,6 +120,10 @@ func ShortNodeName(s string) string {
if len(s) < 10 {
return s
}
// for the rare case of having IPs set as node names
if net.IsIPv4String(s) {
return s
}
before, _, _ := strings.Cut(s, ".")
return before
}