- Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Problem
When using the controller-runtime cache with DefaultNamespaces configured (via ctrl.Options.NewCache), the List() method causes results to accumulate. Each subsequent call to List() includes the results from previous calls, causing the result set to continuously grow.
Steps to Reproduce
- Create a cache with DefaultNamespaces configuration:
mgr, err := ctrl.NewManager(cfg, ctrl.Options{ NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) { opts.DefaultNamespaces = map[string]cache.Config{ "default": {}, } return cache.New(config, opts) }, })- Repeatedly call the List() method in a loop:
pods := &corev1.PodList{} ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) defer cancel() for { select { case <-ctx.Done(): t.Fatal("timeout") default: err := c.List(ctx, pods) // Examine pods.Items length - it grows with each call } }Each call to List() should return the current state of resources, not accumulate previous results. The result set should be reset and then populated with the current state of resources.
- version:
v0.20.4
sbueringer
Metadata
Metadata
Assignees
Labels
No labels