Skip to content

Commit 2458b78

Browse files
authored
fix: candidate controllers missing Forget call in workqueue (#2308)
1 parent fee11af commit 2458b78

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pkg/providers/apisix/apisix_global_rule.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ func (c *apisixGlobalRuleController) sync(ctx context.Context, ev *types.Event)
179179
}
180180

181181
func (c *apisixGlobalRuleController) handleSyncErr(obj interface{}, errOrigin error) {
182+
if errOrigin == nil {
183+
c.MetricsCollector.IncrSyncOperation("GlobalRule", "success")
184+
c.workqueue.Forget(obj)
185+
} else {
186+
c.workqueue.AddRateLimited(obj)
187+
c.MetricsCollector.IncrSyncOperation("GlobalRule", "failure")
188+
}
182189
ev := obj.(*types.Event)
183190
event := ev.Object.(kube.ApisixGlobalRuleEvent)
184191
if k8serrors.IsNotFound(errOrigin) && ev.Type != types.EventDelete {
@@ -219,8 +226,6 @@ func (c *apisixGlobalRuleController) handleSyncErr(obj interface{}, errOrigin er
219226
)
220227
}
221228
}
222-
c.workqueue.Forget(obj)
223-
c.MetricsCollector.IncrSyncOperation("GlobalRule", "success")
224229
return
225230
}
226231
log.Warnw("sync ApisixGlobalRule failed, will retry",
@@ -241,8 +246,6 @@ func (c *apisixGlobalRuleController) handleSyncErr(obj interface{}, errOrigin er
241246
)
242247
}
243248
}
244-
c.workqueue.AddRateLimited(obj)
245-
c.MetricsCollector.IncrSyncOperation("GlobalRule", "failure")
246249
}
247250

248251
func (c *apisixGlobalRuleController) onAdd(obj interface{}) {

0 commit comments

Comments
 (0)