From a3ff91f6a54de54fec57b5446e997daffccfad56 Mon Sep 17 00:00:00 2001 From: yangk Date: Mon, 10 Jan 2022 16:46:18 +0800 Subject: [PATCH] Fix panic caused by error getting cluster version --- util/k8s/k8s.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/k8s/k8s.go b/util/k8s/k8s.go index 3e9d60533..9196d5a5f 100644 --- a/util/k8s/k8s.go +++ b/util/k8s/k8s.go @@ -138,7 +138,11 @@ func IsHighVersion() bool { // GetKubeVersion returns the version of k8s func GetKubeVersion() *utilversion.Version { - var serverVersion, _ = GetClientSet().Discovery().ServerVersion() + var serverVersion, err = GetClientSet().Discovery().ServerVersion() + if err != nil { + logrus.Errorf("Get Kubernetes Version failed [%+v]", err) + return utilversion.MustParseSemantic("v1.19.6") + } return utilversion.MustParseSemantic(serverVersion.GitVersion) }