{"record":{"id":"e959c18bc7724d5f","repo":"kubernetes/kops","slug":"method-listclusters-not-supported-in-server-side-c","errorCode":null,"errorMessage":"method ListClusters not supported in server-side client","messagePattern":"method ListClusters not supported in server-side client","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops-controller/pkg/controllerclientset/clientset.go","lineNumber":97,"sourceCode":"\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}\n\n\treturn newInstanceGroups(c.vfsContext, cluster, c.clusterBasePath)\n}\n\n// AddonsFor returns the client for addon objects for a particular Cluster","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops-controller/pkg/controllerclientset/clientset.go#L79-L115","documentation":"ListClusters is another unimplemented stub in the server-side clientset; the controller operates on a single known cluster, so enumerating all clusters is not supported. Any call returns this error immediately.","triggerScenarios":"Calling client.ListClusters(ctx, metav1.ListOptions{}) from code shared with the CLI, or iterating all clusters (e.g. a multi-cluster reporting or mutation routine) while running inside kops-controller.","commonSituations":"Reusing kops toolbox/CLI code that lists clusters; porting `kops get clusters` style logic into the controller binary.","solutions":["Use the cluster name the controller was configured with (c.clusterName) and call GetCluster instead of listing","Run the listing logic via the `kops` CLI or a VFS-backed clientset outside the controller","If multi-cluster support is needed, deploy one controller per cluster rather than listing"],"exampleFix":"// before\nclusters, err := client.ListClusters(ctx, metav1.ListOptions{})\n// after: use the single configured cluster\ncluster, err := client.GetCluster(ctx, client.ConfigBaseFor(&kops.Cluster{Name: os.Getenv(\"KOPS_CLUSTER_NAME\")}))","handlingStrategy":"fallback","validationCode":"if clusterName == \"\" {\n  return errors.New(\"KOPS_CLUSTER_NAME must be set; server-side clientset cannot list clusters\")\n}","typeGuard":null,"tryCatchPattern":"clusters, err := client.ListClusters(ctx, metav1.ListOptions{})\nif err != nil && strings.Contains(err.Error(), \"ListClusters not supported\") {\n  // fallback: fetch the single configured cluster\n  one, gerr := client.GetCluster(ctx, clusterPath)\n  ...\n}","preventionTips":["Controllers are single-cluster scoped: always use the configured cluster name","Do not port `kops get clusters` logic into kops-controller","Run one controller instance per cluster instead of enumerating"],"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"}