From 6139c51c915f0801fb10153ce81e920a4141c0a7 Mon Sep 17 00:00:00 2001 From: hzma Date: Wed, 20 Nov 2024 18:09:34 +0800 Subject: [PATCH] add not found err check for lb-svc (#4748) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 马洪贞 --- pkg/controller/service.go | 3 +++ pkg/controller/service_lb.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkg/controller/service.go b/pkg/controller/service.go index a3ffbb15f39..6c2cc97d257 100644 --- a/pkg/controller/service.go +++ b/pkg/controller/service.go @@ -358,6 +358,9 @@ func (c *Controller) handleUpdateService(svcObject *updateSvcObject) error { pod, err := c.getLbSvcPod(name, namespace) if err != nil { klog.Errorf("failed to get pod for lb svc %s: %v", key, err) + if strings.Contains(err.Error(), "not found") { + return nil + } return err } diff --git a/pkg/controller/service_lb.go b/pkg/controller/service_lb.go index 914683133ec..24a88b53d8b 100644 --- a/pkg/controller/service_lb.go +++ b/pkg/controller/service_lb.go @@ -415,6 +415,9 @@ func (c *Controller) checkLbSvcDeployAnnotationChanged(svc *corev1.Service) (boo deployName := genLbSvcDpName(svc.Name) deploy, err := c.config.KubeClient.AppsV1().Deployments(svc.Namespace).Get(context.Background(), deployName, metav1.GetOptions{}) if err != nil { + if k8serrors.IsNotFound(err) { + return false, nil + } return false, err }