kubernetes/kubernetes · warning

Couldn't list all objects %v

Error message

Couldn't list all objects %v

What it means

Logged by ClusterRoleAggregationController.enqueue when clusterRoleLister.List(labels.Everything()) returns an error. The lister is a local cache; an error here means the cache itself is in a bad state. After logging, enqueue returns without queueing anything, so aggregation processing stalls until the next enqueue trigger.

Source

Thrown at pkg/controller/clusterroleaggregation/clusterroleaggregation_controller.go:227

	err := c.syncHandler(ctx, dsKey)
	if err == nil {
		c.queue.Forget(dsKey)
		return true
	}

	utilruntime.HandleError(fmt.Errorf("%v failed with : %v", dsKey, err))
	c.queue.AddRateLimited(dsKey)

	return true
}

func (c *ClusterRoleAggregationController) enqueue() {
	// this is unusual, but since the set of all clusterroles is small and we don't know the dependency
	// graph, just queue up every thing each time.  This allows errors to be selectively retried if there
	// is a problem updating a single role
	allClusterRoles, err := c.clusterRoleLister.List(labels.Everything())
	if err != nil {
		utilruntime.HandleError(fmt.Errorf("Couldn't list all objects %v", err))
		return
	}
	for _, clusterRole := range allClusterRoles {
		// only queue ones that we may need to aggregate
		if clusterRole.AggregationRule == nil {
			continue
		}
		key, err := controller.KeyFunc(clusterRole)
		if err != nil {
			utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %v", clusterRole, err))
			return
		}
		c.queue.Add(key)
	}
}

type byName []*rbacv1.ClusterRole

View on GitHub (pinned to 94c1367642)

Solutions

  1. Confirm cache sync completed at startup (WaitForNamedCacheSyncWithContext returned true).
  2. Restart the kube-controller-manager pod if the cache is persistently corrupt.
  3. Check for apiserver connectivity issues causing watch reconnects.
  4. Monitor informer resync metrics; if resync is failing, investigate etcd/apiserver health.

Example fix

// before
allClusterRoles, err := c.clusterRoleLister.List(labels.Everything())
if err != nil {
    utilruntime.HandleError(fmt.Errorf("Couldn't list all objects %v", err))
    return
}
// after: trigger a re-enqueue on next tick so we don't stall silently
allClusterRoles, err := c.clusterRoleLister.List(labels.Everything())
if err != nil {
    utilruntime.HandleError(fmt.Errorf("Couldn't list all objects: %v; will retry enqueue", err))
    c.queue.AddAfter("", 30*time.Second)
    return
}
Defensive patterns

Strategy: retry

Validate before calling

// Confirm the informer has synced before relying on List
if !cache.WaitForCacheSync(ctx.Done(), c.clusterRolesSynced) {
    return fmt.Errorf("ClusterRole cache not synced")
}

Try / catch

all, err := c.clusterRoleLister.List(labels.Everything())
if err != nil {
    utilruntime.HandleError(fmt.Errorf("Couldn't list all objects %v", err))
    c.queue.AddAfter("", 30*time.Second)
    return
}

Prevention

When it happens

Trigger: enqueue() lists all ClusterRoles from the informer cache; failure occurs when the underlying store is unreachable or the cache hasn't synced (rare after WaitForNamedCacheSyncWithContext, but possible on indexer errors).

Common situations: Informer cache desync after a watch disconnect/reconnect storm; memory pressure corrupting the cache; very rare bug in the cache layer; the controller started before its informer factory was ready.

Related errors


AI-assisted analysis of kubernetes/kubernetes@94c1367642 (2026-08-08). Data as JSON: /api/errors/7f685b4474260a43. Report an issue: GitHub.