Empty the list before next round of listing

Empty the list before next round of listing

Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
This commit is contained in:
Wenkai Yin(尹文开)
2024-04-08 13:54:04 +08:00
parent 2c57ed8cbf
commit 27a4bfc7ba

View File

@@ -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