You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by as...@apache.org on 2024/10/14 15:56:35 UTC

(apisix-ingress-controller) branch master updated: fix: candidate controllers missing Forget call in workqueue (#2308)

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

ashishtiwari 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 2458b78f fix: candidate controllers missing Forget call in workqueue (#2308)
2458b78f is described below

commit 2458b78fc69aedf9537bda1e5b4d9006dadf0bc0
Author: Ashish Tiwari <as...@gmail.com>
AuthorDate: Mon Oct 14 21:26:29 2024 +0530

    fix: candidate controllers missing Forget call in workqueue (#2308)
---
 pkg/providers/apisix/apisix_global_rule.go | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/pkg/providers/apisix/apisix_global_rule.go b/pkg/providers/apisix/apisix_global_rule.go
index 69b3d11f..4948543d 100644
--- a/pkg/providers/apisix/apisix_global_rule.go
+++ b/pkg/providers/apisix/apisix_global_rule.go
@@ -179,6 +179,13 @@ func (c *apisixGlobalRuleController) sync(ctx context.Context, ev *types.Event)
 }
 
 func (c *apisixGlobalRuleController) handleSyncErr(obj interface{}, errOrigin error) {
+	if errOrigin == nil {
+		c.MetricsCollector.IncrSyncOperation("GlobalRule", "success")
+		c.workqueue.Forget(obj)
+	} else {
+		c.workqueue.AddRateLimited(obj)
+		c.MetricsCollector.IncrSyncOperation("GlobalRule", "failure")
+	}
 	ev := obj.(*types.Event)
 	event := ev.Object.(kube.ApisixGlobalRuleEvent)
 	if k8serrors.IsNotFound(errOrigin) && ev.Type != types.EventDelete {
@@ -219,8 +226,6 @@ func (c *apisixGlobalRuleController) handleSyncErr(obj interface{}, errOrigin er
 					)
 				}
 			}
-			c.workqueue.Forget(obj)
-			c.MetricsCollector.IncrSyncOperation("GlobalRule", "success")
 			return
 		}
 		log.Warnw("sync ApisixGlobalRule failed, will retry",
@@ -241,8 +246,6 @@ func (c *apisixGlobalRuleController) handleSyncErr(obj interface{}, errOrigin er
 			)
 		}
 	}
-	c.workqueue.AddRateLimited(obj)
-	c.MetricsCollector.IncrSyncOperation("GlobalRule", "failure")
 }
 
 func (c *apisixGlobalRuleController) onAdd(obj interface{}) {