kubernetes/kops · error

error writing Cluster %q: %v

Error message

error writing Cluster %q: %v

What it means

ClusterVFS::Create failed to write the cluster config to the VFS state store. The returned error wraps the underlying vfs error, so the write itself (permissions, backend availability, unexpected existing file) failed after the Create option (WriteOptionCreate) was applied.

Source

Thrown at pkg/client/simple/vfsclientset/cluster.go:119

	if errs := validation.ValidateCluster(c, false, r.vfsContext); len(errs) != 0 {
		return nil, errs.ToAggregate()
	}

	if c.ObjectMeta.CreationTimestamp.IsZero() {
		c.ObjectMeta.CreationTimestamp = metav1.NewTime(time.Now().UTC())
	}

	clusterName := c.ObjectMeta.Name
	if clusterName == "" {
		return nil, fmt.Errorf("clusterName is required")
	}

	if err := r.writeConfig(ctx, c, r.basePath.Join(clusterName, registry.PathCluster), c, vfs.WriteOptionCreate); err != nil {
		if os.IsExist(err) {
			return nil, err
		}
		return nil, fmt.Errorf("error writing Cluster %q: %v", c.ObjectMeta.Name, err)
	}

	return c, nil
}

func (r *ClusterVFS) Update(c *api.Cluster, status *api.ClusterStatus) (*api.Cluster, error) {
	ctx := context.TODO()

	clusterName := c.ObjectMeta.Name
	if clusterName == "" {
		return nil, field.Required(field.NewPath("objectMeta", "name"), "clusterName is required")
	}

	old, err := r.Get(ctx, clusterName, metav1.GetOptions{})
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Read the wrapped %v cause to identify the underlying vfs/backend error
  2. Verify state store credentials and bucket access (e.g. aws s3 ls s3://<bucket>/clusters)
  3. Check whether the cluster already exists — Create uses WriteOptionCreate and will not overwrite
  4. Re-run kops create with correct --state or fix the VFS path
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check backend access
_, err := r.basePath.Join("pki").ReadTree(ctx)
if err != nil {
	return fmt.Errorf("state store not writable/accessible: %w", err)
}

Try / catch

created, err := clusterVFS.Create(ctx, cluster)
if err != nil && strings.Contains(err.Error(), "error writing Cluster") {
	if os.IsExist(err) {
		// cluster already exists — surface as conflict
		return ErrClusterExists
	}
	// otherwise check credentials/bucket, then retry
	return fmt.Errorf("state store write failed, check credentials/bucket: %w", err)
}

Prevention

When it happens

Trigger: Calling Create when the VFS backend is unwritable (bad credentials for s3/gcs, missing bucket, read-only filesystem) or a file already exists at basePath/<name>/pki/cluster and os.IsExist handling propagated it.

Common situations: Cloud storage credentials expired or not configured (e.g. AWS_PROFILE, GOOGLE_APPLICATION_CREDENTIALS); state store bucket deleted or permissions changed; attempting to create a cluster that already exists in the state store.

Related errors


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