kubernetes/kops · error
error writing updated instancegroup configuration: %v
Error message
error writing updated instancegroup configuration: %v
What it means
CreateClusterConfig in pkg/apis/kops/registry/helpers.go writes each InstanceGroup via clientset.InstanceGroupsFor(cluster).Create after the cluster itself has been created. When any single InstanceGroup create fails against the cluster's backing store (state store), the error is wrapped as "error writing updated instancegroup configuration" and creation aborts, potentially leaving a partially provisioned cluster (cluster exists, some instance groups missing).
Source
Thrown at pkg/apis/kops/registry/helpers.go:52
if ns.ObjectMeta.Name == "" {
return fmt.Errorf("InstanceGroup #%d did not have a Name", i+1)
}
if names[ns.ObjectMeta.Name] {
return fmt.Errorf("duplicate InstanceGroup Name found: %q", ns.ObjectMeta.Name)
}
names[ns.ObjectMeta.Name] = true
}
}
_, err := clientset.CreateCluster(ctx, cluster)
if err != nil {
return err
}
for _, ig := range groups {
_, err = clientset.InstanceGroupsFor(cluster).Create(ctx, ig, metav1.CreateOptions{})
if err != nil {
return fmt.Errorf("error writing updated instancegroup configuration: %v", err)
}
}
{
addonsClient := clientset.AddonsFor(cluster)
if err := addonsClient.Replace(addons); err != nil {
return fmt.Errorf("error writing updated addon configuration: %v", err)
}
}
return nil
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Inspect the wrapped %v cause: if it is AlreadyExists, delete/adopt the existing cluster state or use `kops replace`/`kops create -f` update instead of create.
- Verify --state (ConfigStore.Base) points to a writable, existing store and credentials are valid (`kops get clusters` as smoke test).
- Delete partially created cluster state (`kops delete cluster --name <name> --yes`) and retry creation.
- If transient (network/IO), retry CreateClusterConfig; note instance groups created before the failure are not rolled back automatically.
Example fix
// before
_, err = clientset.InstanceGroupsFor(cluster).Create(ctx, ig, metav1.CreateOptions{})
// after
existing, getErr := clientset.InstanceGroupsFor(cluster).Get(ctx, ig.Name, metav1.GetOptions{})
if getErr == nil && existing != nil {
_, err = clientset.InstanceGroupsFor(cluster).Update(ctx, ig, metav1.UpdateOptions{})
} else {
_, err = clientset.InstanceGroupsFor(cluster).Create(ctx, ig, metav1.CreateOptions{})
} Defensive patterns
Strategy: try-catch
Validate before calling
names := map[string]bool{}
for _, ig := range groups {
if ig.Name == "" || names[ig.Name] {
return fmt.Errorf("invalid or duplicate instancegroup name %q", ig.Name)
}
names[ig.Name] = true
}
// also verify state store reachable/writable before creating
if _, err := clientset.GetCluster(ctx, cluster); err == nil {
return fmt.Errorf("cluster %q already exists in state store", cluster.Name)
} Type guard
func isAlreadyExists(err error) bool {
var apiErr apierrors.APIStatus
if errors.As(err, &apiErr) {
return apiErr.Status().Reason == metav1.StatusReasonAlreadyExists
}
return false
} Try / catch
_, err := clientset.InstanceGroupsFor(cluster).Create(ctx, ig, metav1.CreateOptions{})
if err != nil {
if isAlreadyExists(err) {
_, err = clientset.InstanceGroupsFor(cluster).Update(ctx, ig, metav1.UpdateOptions{})
}
if err != nil {
return fmt.Errorf("error writing updated instancegroup configuration: %v", err)
}
} Prevention
- Check for an existing cluster in the state store before running create.
- Validate instance group names are unique and non-empty before calling CreateClusterConfig.
- Confirm state-store credentials and bucket writability with a cheap read/write smoke test.
- Handle AlreadyExists by falling back to Update instead of retrying Create blindly.
When it happens
Trigger: Calling CreateClusterConfig (via `kops create cluster`) when an InstanceGroup with the same name already exists in the state store (AlreadyExists), the state store is unreachable/misconfigured (e.g. bad S3 bucket/permissions), or the VFS path for the cluster cannot be written.
Common situations: Re-running `kops create cluster` against an existing cluster state without `--force` semantics; expired or missing cloud credentials (AWS S3 403); wrong --state flag pointing at a bucket holding stale instancegroups; network outage during cluster creation.
Related errors
- error writing updated addon configuration: %v
- error writing updated configuration: %v
- writing keyset: %v
- unable to check for instanceGroup: %v
- error creating instanceGroup: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/a92087d1af5645ea.
Report an issue: GitHub.