From fc955fd1667a2fa02bd1bd8556b3a06205555366 Mon Sep 17 00:00:00 2001 From: Jiang Biao <862486382@qq.com> Date: Wed, 16 Dec 2020 19:31:34 +0800 Subject: [PATCH] [feat]:update the kubernets.go fix npe (#4338) Signed-off-by: Biao Jiang Co-authored-by: biao.jiang@ximalaya.com --- plugin/kubernetes/kubernetes.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/kubernetes/kubernetes.go b/plugin/kubernetes/kubernetes.go index 991323e76..48d489330 100644 --- a/plugin/kubernetes/kubernetes.go +++ b/plugin/kubernetes/kubernetes.go @@ -252,7 +252,10 @@ func (k *Kubernetes) InitKubeCache(ctx context.Context) (err error) { } // Disable use of endpoint slices for k8s versions 1.18 and earlier. Endpoint slices were // introduced in 1.17 but EndpointSliceMirroring was not added until 1.19. - sv, _ := kubeClient.ServerVersion() + sv, err := kubeClient.ServerVersion() + if err != nil { + return err + } major, _ := strconv.Atoi(sv.Major) minor, _ := strconv.Atoi(sv.Minor) if k.opts.useEndpointSlices && major <= 1 && minor <= 18 {