From 576dfd427a9d4ce052b61732c3739be704887b4d 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 7bd63777028..1bb6c41a980 100644 --- a/pkg/controller/service.go +++ b/pkg/controller/service.go @@ -457,6 +457,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 24f54ba81ab..3def07107e9 100644 --- a/pkg/controller/service_lb.go +++ b/pkg/controller/service_lb.go @@ -351,6 +351,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 }