{"record":{"id":"207e2ccbf08fe1f2","repo":"kubernetes/kops","slug":"error-removing-cluster-from-state-store-v","errorCode":null,"errorMessage":"error removing cluster from state store: %v","messagePattern":"error removing cluster from state store: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/delete_cluster.go","lineNumber":222,"sourceCode":"\t\t}\n\t}\n\n\tif !options.External {\n\t\tif !options.Yes {\n\t\t\tif wouldDeleteCloudResources {\n\t\t\t\tfmt.Fprintf(out, \"\\nMust specify --yes to delete cloud resources & unregister cluster\\n\")\n\t\t\t} else {\n\t\t\t\tfmt.Fprintf(out, \"\\nMust specify --yes to unregister the cluster\\n\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t\tclientset, err := f.KopsClient()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = clientset.DeleteCluster(ctx, cluster)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error removing cluster from state store: %v\", err)\n\t\t}\n\t}\n\n\tb := kubeconfig.NewKubeconfigBuilder()\n\tb.Context = clusterName\n\terr = b.DeleteKubeConfig(clientcmd.NewDefaultPathOptions())\n\tif err != nil {\n\t\tklog.Warningf(\"error removing kube config: %v\", err)\n\t}\n\n\tfmt.Fprintf(out, \"\\nDeleted cluster: %q\\n\", clusterName)\n\treturn nil\n}\n\nfunc completeRegion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {\n\t// TODO call into cloud provider(s) to get list of valid regions\n\treturn nil, cobra.ShellCompDirectiveNoFileComp\n}","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/delete_cluster.go#L204-L240","documentation":"After deleting (or while finalizing) cluster deletion, RunDeleteCluster calls clientset.DeleteCluster to remove the cluster's configuration from the kOps state store (S3/GCS/etc.). If the registry delete fails, the underlying error is wrapped with this message.","triggerScenarios":"State store backend errors during DeleteCluster: insufficient IAM permissions on the S3 bucket, object already removed/concurrency conflict, network failure to the state store, or a non-empty/locked registry.","commonSituations":"S3 bucket policy denies s3:DeleteObject; state store was manually cleaned so the cluster config no longer exists; transient network outage; credentials scoped to read-only.","solutions":["Read the wrapped %v error to identify the backend failure and fix permissions (e.g. grant s3:DeleteObject on the state store prefix).","Verify the cluster config still exists: `kops get cluster --name <name>`; if already gone, the delete can be considered done.","Retry after network issues; if the state store entry is stuck, remove it manually with `kops delete cluster` again or delete the S3 objects under /clusters/<name>."],"exampleFix":"// before (IAM policy)\n{\"Action\":[\"s3:ListBucket\",\"s3:GetObject\"], ...}\n// after\n{\"Action\":[\"s3:ListBucket\",\"s3:GetObject\",\"s3:DeleteObject\",\"s3:DeleteObjectVersion\"], ...}","handlingStrategy":"retry","validationCode":"if err := exec.Command(\"kops\", \"get\", \"cluster\", \"--name\", clusterName).Run(); err != nil {\n    // cluster config already absent from state store; skip delete\n}","typeGuard":null,"tryCatchPattern":"if err := runDeleteCluster(...); err != nil && strings.Contains(err.Error(), \"state store\") {\n    // inspect wrapped cause; fix IAM/network; retry with backoff\n}","preventionTips":["Grant s3:DeleteObject/DeleteObjectVersion on the state store prefix.","Verify KOPS_STATE_STORE connectivity before deletion.","Treat 'already gone' from the wrapped error as success in idempotent scripts."],"tags":["state-store","s3","permissions"],"backgroundTag":"state-store-delete-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}