{"record":{"id":"7fcc13f248f82ca4","repo":"GoogleContainerTools/skaffold","slug":"getting-pods-for-namespace-q-w-7fcc13","errorCode":null,"errorMessage":"getting pods for namespace %q: %w","messagePattern":"getting pods for namespace %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/sync/sync.go","lineNumber":345,"sourceCode":"\tif len(files) == 0 {\n\t\treturn nil\n\t}\n\n\terrs, ctx := errgroup.WithContext(ctx)\n\n\tclient, err := kubernetesclient.Client(kubeContext)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting Kubernetes client: %w\", err)\n\t}\n\n\tnumSynced := 0\n\tfor _, ns := range namespaces {\n\t\tpods, err := client.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{\n\t\t\tFieldSelector: fmt.Sprintf(\"status.phase=%s\", v1.PodRunning),\n\t\t})\n\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"getting pods for namespace %q: %w\", ns, err)\n\t\t}\n\n\t\tif len(pods.Items) == 0 {\n\t\t\tlog.Entry(ctx).Warnf(\"no running pods found in namespace %q\", ns)\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, p := range pods.Items {\n\t\t\tfor _, c := range p.Spec.Containers {\n\t\t\t\tif c.Image != image {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tcmd := cmdFn(ctx, p, c, files)\n\t\t\t\terrs.Go(func() error {\n\t\t\t\t\t_, err := util.RunCmdOut(ctx, cmd)\n\t\t\t\t\treturn err\n\t\t\t\t})","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/sync/sync.go#L327-L363","documentation":"The API call listing running pods in one of the target namespaces failed during sync. `client.CoreV1().Pods(ns).List` returned an error, which is wrapped with the namespace name for context. This happens before any file-copy/delete is executed on pods.","triggerScenarios":"`Perform` iterates `namespaces` and calls `Pods(ns).List(ctx, metav1.ListOptions{FieldSelector: \"status.phase=Running\"})`; a network error, timeout, or RBAC denial produces this error.","commonSituations":"Cluster unreachable / VPN down; service account lacks `list pods` permission in that namespace; context points at the wrong cluster; API server temporarily unavailable.","solutions":["Run `kubectl get pods -n <ns>` with the same context to reproduce and see the raw error","Check RBAC: the identity needs pods/list in the namespace (clusterrole or rolebinding)","Verify network/VPN connectivity to the cluster API server","Retry once the API server recovers if it was a transient 5xx/timeout"],"exampleFix":"// before: role without pod list permission\nkubectl auth can-i list pods -n default # -> no\n// after\nkubectl create rolebinding skaffold-pods --clusterrole=view --user=<user> -n default","handlingStrategy":"retry","validationCode":"// pre-check RBAC and reachability\nallowed, _ := kubeClient.AuthorizationV1().SelfSubjectAccessReviews().Create(ctx,\n    &authv1.SelfSubjectAccessReview{Spec: authv1.SelfSubjectAccessReviewSpec{\n        ResourceAttributes: &authv1.ResourceAttributes{Verb: \"list\", Resource: \"pods\", Namespace: ns}}})\nif !allowed.Status.Allowed { return fmt.Errorf(\"no pods/list RBAC in %s\", ns) }","typeGuard":null,"tryCatchPattern":"errgroup inside Perform already retries per-namespace listing at the caller level; wrap with backoff:\nerr := retry.Do(func() error { _, e := client.CoreV1().Pods(ns).List(ctx, opts); return e }, retry.Attempts(3))\nif err != nil && strings.Contains(err.Error(), \"getting pods for namespace\") {\n    log.Warnf(\"pod listing failed for ns=%s: %v\", ns, errors.Unwrap(err))\n}","preventionTips":["Grant pods/list via rolebinding before dev","Check VPN/cluster connectivity before running skaffold dev","Handle transient API server outages with retry+backoff","Verify field selector support (Running phase) with kubectl get pods --field-selector"],"tags":["kubernetes","rbac","pod-list"],"backgroundTag":"kubernetes-api-forbidden","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}