{"record":{"id":"07e8932dab861366","repo":"kubernetes/kops","slug":"method-deletecluster-not-supported-in-server-side","errorCode":null,"errorMessage":"method DeleteCluster not supported in server-side client","messagePattern":"method DeleteCluster not supported in server-side client","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops-controller/pkg/controllerclientset/clientset.go","lineNumber":169,"sourceCode":"\t\tklog.Fatalf(\"clientset bound to cluster %q, got cluster %q\", c.clusterName, clusterName)\n\t}\n\n\treturn c.clusterKeystore, nil\n}\n\n// SSHCredentialStore builds the SSHCredential store for the specified cluster\nfunc (c *client) SSHCredentialStore(cluster *kops.Cluster) (fi.SSHCredentialStore, error) {\n\tclusterName := cluster.Name\n\tif clusterName != c.clusterName {\n\t\tklog.Fatalf(\"clientset bound to cluster %q, got cluster %q\", c.clusterName, clusterName)\n\t}\n\n\treturn newSSHCredentialStore(c.clusterBasePath, cluster), nil\n}\n\n// DeleteCluster deletes all the state for the specified cluster\nfunc (c *client) DeleteCluster(ctx context.Context, cluster *kops.Cluster) error {\n\treturn fmt.Errorf(\"method DeleteCluster not supported in server-side client\")\n}\n","sourceCodeStart":151,"sourceCodeEnd":171,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops-controller/pkg/controllerclientset/clientset.go#L151-L171","documentation":"The server-side (in-cluster) clientset intentionally does not implement cluster deletion: DeleteCluster on this client always returns this error. It is a permanent capability limitation by design, not a transient or input-dependent failure.","triggerScenarios":"Calling client.DeleteCluster(ctx, cluster) from code running in kops-controller, e.g. a cleanup or lifecycle-management routine reusing CLI deletion logic.","commonSituations":"Porting `kops delete cluster` logic into an operator; adding an auto-cleanup feature to the controller.","solutions":["Perform cluster deletion exclusively via the `kops delete cluster` CLI, with its confirmation flow","If automated deletion is required, invoke the CLI from a dedicated job/operator, never from kops-controller","Keep the controller strictly read/manage for an already-provisioned cluster"],"exampleFix":"// before\nerr := client.DeleteCluster(ctx, cluster)\n// after: deletion is a CLI operation\n// $ kops delete cluster --name mycluster.example.com --yes","handlingStrategy":"validation","validationCode":"if isServerSideClientset(client) {\n  return errors.New(\"cluster deletion must be done via `kops delete cluster` CLI with confirmation\")\n}","typeGuard":null,"tryCatchPattern":"err := client.DeleteCluster(ctx, cluster)\nif err != nil && strings.Contains(err.Error(), \"DeleteCluster not supported\") {\n  // delegate to CLI with explicit --yes\n  return exec.CommandContext(ctx, \"kops\", \"delete\", \"cluster\", \"--name\", cluster.Name, \"--yes\").Run()\n}","preventionTips":["Never attempt destructive lifecycle ops from kops-controller","Require human confirmation (CLI --yes) for deletion flows","Audit code for DeleteCluster calls before deploying controller changes"],"tags":["go","unsupported-operation","kops","destructive-operation"],"backgroundTag":"operation-not-supported-by-client","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"}