From 91774af54d1d2b17bb78901964ca00c5f231e8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wenkai=20Yin=28=E5=B0=B9=E6=96=87=E5=BC=80=29?= Date: Mon, 8 Apr 2024 13:54:04 +0800 Subject: [PATCH] Empty the list before next round of listing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Empty the list before next round of listing Signed-off-by: Wenkai Yin(尹文开) --- pkg/util/kube/periodical_enqueue_source.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/util/kube/periodical_enqueue_source.go b/pkg/util/kube/periodical_enqueue_source.go index 885767f605..b4c4f27b8e 100644 --- a/pkg/util/kube/periodical_enqueue_source.go +++ b/pkg/util/kube/periodical_enqueue_source.go @@ -69,6 +69,11 @@ type PeriodicalEnqueueSourceOption struct { func (p *PeriodicalEnqueueSource) Start(ctx context.Context, h handler.EventHandler, q workqueue.RateLimitingInterface, predicates ...predicate.Predicate) error { go wait.Until(func() { p.logger.Debug("enqueueing resources ...") + // empty the list otherwise the result of the new list call will be appended + if err := meta.SetList(p.objList, nil); err != nil { + p.logger.WithError(err).Error("error reset resource list") + return + } if err := p.List(ctx, p.objList); err != nil { p.logger.WithError(err).Error("error listing resources") return