You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by zh...@apache.org on 2022/03/04 10:09:20 UTC

[apisix-ingress-controller] branch master updated: fetching newest Endpoint before sync (#821)

This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new b5448c3  fetching newest Endpoint before sync (#821)
b5448c3 is described below

commit b5448c37e7b043b4d2a5b5d35b115429a20760a0
Author: chen zhuo <ch...@126.com>
AuthorDate: Fri Mar 4 18:09:16 2022 +0800

    fetching newest Endpoint before sync (#821)
---
 pkg/ingress/endpoint.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/pkg/ingress/endpoint.go b/pkg/ingress/endpoint.go
index 9464d59..912958c 100644
--- a/pkg/ingress/endpoint.go
+++ b/pkg/ingress/endpoint.go
@@ -20,6 +20,7 @@ import (
 
 	"go.uber.org/zap"
 	corev1 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/api/errors"
 	"k8s.io/client-go/tools/cache"
 	"k8s.io/client-go/util/workqueue"
 
@@ -84,7 +85,14 @@ func (c *endpointsController) run(ctx context.Context) {
 
 func (c *endpointsController) sync(ctx context.Context, ev *types.Event) error {
 	ep := ev.Object.(kube.Endpoint)
-	return c.controller.syncEndpoint(ctx, ep)
+	newestEp, err := c.controller.epLister.GetEndpoint(ep.Namespace(), ep.ServiceName())
+	if err != nil {
+		if !errors.IsNotFound(err) {
+			return err
+		}
+		newestEp = ep
+	}
+	return c.controller.syncEndpoint(ctx, newestEp)
 }
 
 func (c *endpointsController) handleSyncErr(obj interface{}, err error) {