{"record":{"id":"d632844539b83aad","repo":"kubernetes/kops","slug":"method-updatecluster-not-supported-in-server-side","errorCode":null,"errorMessage":"method UpdateCluster not supported in server-side client","messagePattern":"method UpdateCluster not supported in server-side client","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops-controller/pkg/controllerclientset/clientset.go","lineNumber":92,"sourceCode":"\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected kind for cluster, got %T, want kops.Cluster\", object)\n\t}\n\treturn cluster, nil\n}\n\n// VFSContext returns a VFSContext.\nfunc (c *client) VFSContext() *vfs.VFSContext {\n\treturn c.vfsContext\n}\n\n// CreateCluster creates a cluster\nfunc (c *client) CreateCluster(ctx context.Context, cluster *kops.Cluster) (*kops.Cluster, error) {\n\treturn nil, fmt.Errorf(\"method CreateCluster not supported in server-side client\")\n}\n\n// UpdateCluster updates a cluster\nfunc (c *client) UpdateCluster(ctx context.Context, cluster *kops.Cluster, status *kops.ClusterStatus) (*kops.Cluster, error) {\n\treturn nil, fmt.Errorf(\"method UpdateCluster not supported in server-side client\")\n}\n\n// ListClusters returns all clusters\nfunc (c *client) ListClusters(ctx context.Context, options metav1.ListOptions) (*kops.ClusterList, error) {\n\treturn nil, fmt.Errorf(\"method ListClusters not supported in server-side client\")\n}\n\n// ConfigBaseFor returns the vfs path where we will read configuration information from\nfunc (c *client) ConfigBaseFor(cluster *kops.Cluster) (vfs.Path, error) {\n\treturn nil, fmt.Errorf(\"method ConfigBaseFor not supported in server-side client\")\n}\n\n// InstanceGroupsFor returns the InstanceGroupInterface bound to the namespace for a particular Cluster\nfunc (c *client) InstanceGroupsFor(cluster *kops.Cluster) kopsinternalversion.InstanceGroupInterface {\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}","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops-controller/pkg/controllerclientset/clientset.go#L74-L110","documentation":"Like CreateCluster, UpdateCluster is intentionally unimplemented in the server-side clientset: mutating cluster spec/status through the controller client is not supported. The method exists only to satisfy the interface and always returns this error.","triggerScenarios":"Calling client.UpdateCluster(ctx, cluster, status) from controller code, typically after GetCluster, attempting to persist spec or status changes to the state store.","commonSituations":"Porting CLI/upgrade logic (e.g. `kops update cluster` or status updating) into the controller; writing a reconciliation loop that tries to write back cluster changes.","solutions":["Avoid mutating cluster objects from kops-controller; apply changes via the `kops` CLI (kops update cluster / kops replace -f)","Use a VFS-backed clientset if programmatic writes are required in a tool you control","Store controller-local state in a separate object/ConfigMap rather than the kops Cluster object"],"exampleFix":"// before\n_, err = client.UpdateCluster(ctx, cluster, status)\n// after: run mutations outside the controller\n// $ kops replace -f cluster.yaml\n// controller only reads:\ncluster, err := client.GetCluster(ctx, clusterPath)","handlingStrategy":"try-catch","validationCode":"if isServerSideClientset(client) {\n  return errors.New(\"UpdateCluster is not supported server-side; apply changes via kops CLI\")\n}","typeGuard":null,"tryCatchPattern":"_, err := client.UpdateCluster(ctx, cluster, status)\nif err != nil && strings.Contains(err.Error(), \"UpdateCluster not supported\") {\n  // execute: kops replace -f cluster.yaml && kops update cluster --yes\n  return applyViaKopsCLI(ctx, cluster)\n}","preventionTips":["Never mutate cluster spec/status from controller code","Use declarative YAML + `kops replace`/`kops update` for changes","Document in team runbooks that server-side clientset is read-oriented"],"tags":["go","unsupported-operation","kops","server-side-client"],"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"}