{"record":{"id":"b6eab23b100a79ee","repo":"kubernetes/kops","slug":"error-creating-cluster-v-b6eab2","errorCode":null,"errorMessage":"error creating cluster: %v","messagePattern":"error creating cluster: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/replace.go","lineNumber":150,"sourceCode":"\t\t\t\t\t\tif errors.IsNotFound(err) {\n\t\t\t\t\t\t\tcluster = nil\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"error fetching cluster %q: %v\", clusterName, err)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif cluster == nil {\n\t\t\t\t\t\tif !c.Force {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"cluster %v does not exist (try adding --force flag)\", clusterName)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\terr = cloudup.PerformAssignments(v, vfsContext, cloud)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"error populating configuration: %w\", err)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t_, err = clientset.CreateCluster(ctx, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"error creating cluster: %v\", err)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t_, err = clientset.UpdateCluster(ctx, v, status)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"error replacing cluster: %v\", err)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tcase *kopsapi.InstanceGroup:\n\t\t\t\tclusterName := v.ObjectMeta.Labels[kopsapi.LabelClusterName]\n\t\t\t\tif clusterName == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"must specify %q label with cluster name to replace instanceGroup\", kopsapi.LabelClusterName)\n\t\t\t\t}\n\t\t\t\tcluster, err := clientset.GetCluster(ctx, clusterName)\n\t\t\t\tif err != nil {\n\t\t\t\t\tif errors.IsNotFound(err) {\n\t\t\t\t\t\treturn fmt.Errorf(\"cluster %q not found\", clusterName)","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/replace.go#L132-L168","documentation":"Wraps a failure of clientset.CreateCluster while `kops replace --force` was creating a brand-new cluster in the state store. The create call (not the config parsing) failed; the underlying API/registry error is carried in %v.","triggerScenarios":"CreateCluster failing due to an unwritable state store (permissions, quota), an invalid cluster spec rejected by validation, a conflict because the object was concurrently created, or serialization issues with the API version.","commonSituations":"State store bucket is read-only or credentials lack write access; bucket region/permissions changed; cluster was created by another process between the Get and Create; malformed spec (e.g. invalid kubernetesVersion or networking config).","solutions":["Check write permissions on the state store bucket/container and credentials","Re-run with `kops get clusters` to see if the cluster now exists (race) and use replace/update instead","Validate the manifest spec (`kops replace` decodes strictly; fix invalid fields like kubernetesVersion, networking)","Confirm the state store is healthy (no lifecycle rules deleting objects, no SSE/KMS access issues)","Read the wrapped %v error for the exact backend or validation cause"],"exampleFix":"// before\naws s3api put-object --bucket my-state-store --key test  # AccessDenied\n// after\n# fix IAM policy to allow s3:PutObject on the state store bucket\nkops replace -f cluster.yaml --force","handlingStrategy":"retry","validationCode":"// ensure state store is writable\nkey := path.Join(stateStore, \"test-write-probe\")\nif err := writeProbe(stateStore); err != nil {\n    return fmt.Errorf(\"state store not writable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"_, err := clientset.CreateCluster(ctx, v)\nif err != nil {\n    if isConflict(err) {\n        // cluster created concurrently: fall back to update path\n    } else if isTransient(err) {\n        // retry with backoff\n    }\n    return err\n}","preventionTips":["Grant write (PutObject) permissions for CI/service roles on the state store","Avoid concurrent create of the same cluster from multiple jobs","Validate the spec against the supported schema before create","Watch for bucket lifecycle rules or KMS policies blocking writes"],"tags":["state-store","cluster","api"],"backgroundTag":"state-store-write-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}