diff --git a/utils/ingress/ingress.go b/utils/ingress/ingress.go index e2662e0ddb..ad9c9ee316 100644 --- a/utils/ingress/ingress.go +++ b/utils/ingress/ingress.go @@ -275,7 +275,11 @@ func DetermineIngressMode(apiVersion string, d discovery.ServerVersionInterface) if err != nil { return 0, err } - minor, err := strconv.Atoi(ver.Minor) + verMinor := ver.Minor + if strings.HasSuffix(ver.Minor, "+") { + verMinor = ver.Minor[0 : len(ver.Minor)-1] + } + minor, err := strconv.Atoi(verMinor) if err != nil { return 0, err } @@ -286,5 +290,4 @@ func DetermineIngressMode(apiVersion string, d discovery.ServerVersionInterface) return IngressModeNetworking, nil } return IngressModeExtensions, nil - } diff --git a/utils/ingress/ingress_test.go b/utils/ingress/ingress_test.go index 36a013ee4a..eaca7e6a86 100644 --- a/utils/ingress/ingress_test.go +++ b/utils/ingress/ingress_test.go @@ -329,6 +329,12 @@ func TestDetermineIngressMode(t *testing.T) { faKeDiscovery: newFakeDiscovery("1", "18", nil), expectedMode: IngressModeExtensions, }, + { + name: "will return networking mode if server minor version has '+' suffix, e.g. 1.19+", + apiVersion: "", + faKeDiscovery: newFakeDiscovery("1", "19+", nil), + expectedMode: IngressModeNetworking, + }, { name: "will return error if fails to retrieve server version", apiVersion: "", @@ -358,6 +364,28 @@ func TestDetermineIngressMode(t *testing.T) { Err: errors.New("invalid syntax"), }, }, + { + name: "will return error if fails to parse minor version with '+' suffix, e.g. 1.wrong+", + apiVersion: "", + faKeDiscovery: newFakeDiscovery("1", "wrong+", nil), + expectedMode: 0, + expectedError: &strconv.NumError{ + Func: "Atoi", + Num: "wrong", + Err: errors.New("invalid syntax"), + }, + }, + { + name: "will return error if fails to parse minor version with just '+'", + apiVersion: "", + faKeDiscovery: newFakeDiscovery("1", "+", nil), + expectedMode: 0, + expectedError: &strconv.NumError{ + Func: "Atoi", + Num: "", + Err: errors.New("invalid syntax"), + }, + }, } for _, c := range cases { c := c // necessary to ensure all test cases are executed when running in parallel mode