GoogleContainerTools/skaffold · error

STATUSCHECK_STATEFULSET_FETCH_ERR

STATUSCHECK_STATEFULSET_FETCH_ERR

Error message

could not fetch statefulsets: %w

What it means

Same pattern as deployments: statusCheck wraps any error listing StatefulSets with this message and STATUSCHECK_STATEFULSET_FETCH_ERR. It originates from getStatefulSets calling client.AppsV1().StatefulSets(ns).List(...).

Source

Thrown at pkg/skaffold/kubernetes/status/status_check.go:196

		return proto.StatusCode_STATUSCHECK_KUBECTL_CLIENT_FETCH_ERR, fmt.Errorf("getting Kubernetes client: %w", err)
	}
	resources := make([]*resource.Resource, 0)
	for _, n := range *s.namespaces {
		newDeployments, err := getDeployments(ctx, client, n, s.labeller, getDeadline(s.deadlineSeconds), s.tolerateFailures)
		if err != nil {
			return proto.StatusCode_STATUSCHECK_DEPLOYMENT_FETCH_ERR, fmt.Errorf("could not fetch deployments: %w", err)
		}
		for _, d := range newDeployments {
			if s.seenResources.Contains(d) {
				continue
			}
			resources = append(resources, d)
			s.seenResources.Add(d)
		}

		newStatefulSets, err := getStatefulSets(ctx, client, n, s.labeller, getDeadline(s.deadlineSeconds), s.tolerateFailures)
		if err != nil {
			return proto.StatusCode_STATUSCHECK_STATEFULSET_FETCH_ERR, fmt.Errorf("could not fetch statefulsets: %w", err)
		}
		for _, d := range newStatefulSets {
			if s.seenResources.Contains(d) {
				continue
			}
			resources = append(resources, d)
			s.seenResources.Add(d)
		}

		newStandalonePods, err := getStandalonePods(ctx, client, n, s.labeller, getDeadline((s.deadlineSeconds)), s.tolerateFailures)
		if err != nil {
			return proto.StatusCode_STATUSCHECK_STANDALONE_PODS_FETCH_ERR, fmt.Errorf("could not fetch standalone pods: %w", err)
		}
		for _, pods := range newStandalonePods {
			if s.seenResources.Contains(pods) {
				continue
			}
			resources = append(resources, pods)

View on GitHub (pinned to a1189de023)

Solutions

  1. Check 'kubectl auth can-i list statefulsets.apps -n <ns>'
  2. Verify namespace and context, then 'kubectl get statefulsets -n <ns>' directly
  3. Add statefulsets.apps get/list/watch to the RBAC role if denied
  4. Fix kubeconfig/credentials (re-authenticate, e.g. gcloud container clusters get-credentials)
  5. Retry after restoring API server connectivity

Example fix

// before: role without statefulsets
//   kubectl create role dev --verb=get,list --resource=deployments.apps
// after:
//   kubectl create role dev --verb=get,list,watch --resource=deployments.apps,statefulsets.apps
Defensive patterns

Strategy: try-catch

Validate before calling

const canList = execSync(`kubectl auth can-i list statefulsets.apps -n ${ns}`).toString().trim();
if (canList !== 'yes') throw new Error(`RBAC: cannot list statefulsets in ${ns}`);

Type guard

function isStatefulSetFetchErr(err) {
  return err != null && typeof err.message === 'string' && err.message.includes('could not fetch statefulsets');
}

Try / catch

try {
  await statusCheck();
} catch (err) {
  if (err.message.includes('could not fetch statefulsets')) {
    log.error('statefulset list failed:', err.cause ?? err.message);
  }
  throw err;
}

Prevention

When it happens

Trigger: client.AppsV1().StatefulSets(ns).List fails per namespace: RBAC denial on statefulsets.apps, missing namespace, unreachable API server, or transport error.

Common situations: Cluster where the RBAC role covers deployments but not statefulsets; namespace typo; cluster upgraded/credentials rotated mid-run; private-cluster firewall blocking the control plane.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/08c6d555dbb37c4b. Report an issue: GitHub.