kubernetes/kops · error

error listing %s in state store: %v

Error message

error listing %s in state store: %v

What it means

listNames enumerates child names of the clientset basePath via listChildNames. Any listing error from the VFS backend is wrapped as "error listing <kind> in state store". It means the state-store directory could not be read at all.

Source

Thrown at pkg/client/simple/vfsclientset/commonvfs.go:220

	return nil
}

func (c *VFSClientBase) delete(ctx context.Context, name string, options metav1.DeleteOptions) error {
	p := c.basePath.Join(name)
	err := p.Remove(ctx)
	if err != nil {
		if os.IsNotExist(err) {
			return nil
		}
		return fmt.Errorf("error deleting %s configuration %q: %v", c.kind, name, err)
	}
	return nil
}

func (c *VFSClientBase) listNames(ctx context.Context) ([]string, error) {
	keys, err := listChildNames(ctx, c.basePath)
	if err != nil {
		return nil, fmt.Errorf("error listing %s in state store: %v", c.kind, err)
	}

	// Seems to be an assumption in k8s APIs that items are always returned sorted
	sort.Strings(keys)

	return keys, nil
}

func (c *VFSClientBase) readAll(ctx context.Context, items interface{}) (interface{}, error) {
	sliceValue := reflect.ValueOf(items)
	sliceType := reflect.TypeOf(items)
	if sliceType.Kind() != reflect.Slice {
		return nil, fmt.Errorf("expected slice, got %T", items)
	}

	names, err := c.listNames(ctx)
	if err != nil {
		return nil, err

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Validate the state store location exists and is readable (aws s3 ls s3://bucket/cluster-name/instancegroups).
  2. Refresh cloud credentials.
  3. Correct KOPS_STATE_STORE / --state flag value.
  4. Retry after network issues resolve.

Example fix

// before
KOPS_STATE_STORE=s3://old-bucket kops get instancegroups
// after
KOPS_STATE_STORE=s3://my-state-bucket kops get instancegroups
Defensive patterns

Strategy: try-catch

Validate before calling

_, err := store.ReadFile(ctx, basePath)
if err != nil {
    return fmt.Errorf("state store base path unreadable: %w", err)
}

Try / catch

items, err := client.List(ctx, metav1.ListOptions{})
if err != nil {
    if strings.Contains(err.Error(), "error listing") {
        // check credentials / KOPS_STATE_STORE, then retry
        return refreshCredsAndRetry()
    }
    return err
}

Prevention

When it happens

Trigger: List/readAll calls listNames and the vfs directory listing fails: missing basePath, permission denied, invalid credentials, or backend unreachable.

Common situations: `kops get` against a deleted or never-initialized state bucket, expired cloud credentials, wrong KOPS_STATE_STORE path, network partition, bucket region mismatch.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/0ca65f7765e6684e. Report an issue: GitHub.