diff --git a/pkg/k8sutil/clientset.go b/pkg/k8sutil/clientset.go index 99de2ae..d10ec51 100644 --- a/pkg/k8sutil/clientset.go +++ b/pkg/k8sutil/clientset.go @@ -1,6 +1,7 @@ package k8sutil import ( + "regexp" "strconv" "github.com/pkg/errors" @@ -76,7 +77,15 @@ func GetK8sMinorVersion(clientset kubernetes.Interface) (int, error) { return -1, errors.Wrap(err, "failed to get kubernetes server version") } - k8sMinorVersion, err := strconv.Atoi(k8sVersion.Minor) + // remove + sign from Minor version if any (for EKS) + // https://github.com/aws/containers-roadmap/issues/1404 + reg := regexp.MustCompile(`[0-9]+`) + minorVersion := reg.FindString(k8sVersion.Minor) + if minorVersion == "" { + return -1, errors.New("failed to get k8s minor version") + } + + k8sMinorVersion, err := strconv.Atoi(minorVersion) if err != nil { return -1, errors.Wrap(err, "failed to convert k8s minor version to int") } diff --git a/pkg/k8sutil/clientset_test.go b/pkg/k8sutil/clientset_test.go index 51ecb61..bbbd66a 100644 --- a/pkg/k8sutil/clientset_test.go +++ b/pkg/k8sutil/clientset_test.go @@ -31,6 +31,7 @@ func TestGetK8sMinorVersion(t *testing.T) { {"expect minor version 22", args{mockClientsetK8sVersion("1", "22")}, 22, false}, {"expect minor version 21", args{mockClientsetK8sVersion("1", "21")}, 21, false}, {"expect minor version conversion error", args{mockClientsetK8sVersion("1", "a")}, -1, true}, + {"expect minor version 30", args{mockClientsetK8sVersion("1", "30+")}, 30, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {