amir20/dozzle · error

no namespaces to watch

Error message

no namespaces to watch

What it means

ContainerEvents returns this error when it could not build any namespace watchers, so there is nothing to watch for pod/container events. It is raised when the pre-built watcher list is empty after iterating the configured namespaces (internal/k8s/client.go:582).

Solutions

  1. Check which namespaces the client was configured with and ensure at least one is valid/watchable.
  2. Verify RBAC: the service account needs list/watch on pods (and namespaces) — kubectl auth can-i list pods -n <ns>.
  3. Run kubectl get namespaces to confirm the cluster actually has accessible namespaces from Dozzle's context.
  4. If you restrict namespaces via config, make sure the configured names exist and are not filtered out.
Defensive patterns

Strategy: validation

Validate before calling

kubectl auth can-i list pods --all-namespaces --as=system:serviceaccount:<ns>:dozzle
kubectl get namespaces

Prevention

When it happens

Trigger: Calling ContainerEvents on a k8s client where every namespace failed to produce a watcher — e.g. no namespaces resolved/configured, or all watcher constructions were skipped before the len(watchers)==0 guard.

Common situations: Running Dozzle in k8s mode in a cluster/namespace context where the service account can't see any namespace or the namespace list is empty; misconfigured namespace restriction excluding everything; RBAC so limited that watcher setup yields nothing.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of amir20/dozzle@d9463cbe21 (2026-09-07). Data as JSON: /api/errors/d1e78b8a9efc6389. Report an issue: GitHub.

Appendix: source

Thrown at internal/k8s/client.go:582

		Timestamps: true,
		SinceTime:  &metav1.Time{Time: start},
	}

	return k.Clientset.CoreV1().Pods(namespace).GetLogs(podName, opts).Stream(ctx)
}

func (k *K8sClient) ContainerEvents(ctx context.Context, ch chan<- container.ContainerEvent) error {
	watchers := lo.Map(k.namespace, func(namespace string, index int) watch.Interface {
		watcher, err := k.Clientset.CoreV1().Pods(namespace).Watch(ctx, metav1.ListOptions{})
		if err != nil {
			log.Error().Err(err).Msg("Failed to watch pods")
			return nil
		}
		return watcher
	})

	if len(watchers) == 0 {
		return errors.New("no namespaces to watch")
	}

	wg := sync.WaitGroup{}

	for _, watcher := range watchers {
		wg.Go(func() {
			for event := range watcher.ResultChan() {
				log.Debug().Interface("event.type", event.Type).Msg("Received kubernetes event")
				pod, ok := event.Object.(*corev1.Pod)
				if !ok {
					continue
				}

				name := ""
				switch event.Type {
				case "ADDED":
					name = "create"
				case "DELETED":

View on GitHub (pinned to d9463cbe21)