{"record":{"id":"3d21b73c18f5a6f0","repo":"kubernetes/kops","slug":"cluster-q-not-found-3d21b7","errorCode":null,"errorMessage":"cluster %q not found","messagePattern":"cluster %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/toolbox_enroll.go","lineNumber":664,"sourceCode":"func (b *ConfigBuilder) GetCluster(ctx context.Context) (*kops.Cluster, error) {\n\tif b.Cluster != nil {\n\t\treturn b.Cluster, nil\n\t}\n\n\tif b.ClusterName == \"\" {\n\t\treturn nil, fmt.Errorf(\"ClusterName is missing\")\n\t}\n\n\tclientset, err := b.GetClientset(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcluster, err := clientset.GetCluster(ctx, b.ClusterName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif cluster == nil {\n\t\treturn nil, fmt.Errorf(\"cluster %q not found\", b.ClusterName)\n\t}\n\tb.Cluster = cluster\n\treturn cluster, nil\n}\n\nfunc (b *ConfigBuilder) GetAssetBuilder(ctx context.Context) (*assets.AssetBuilder, error) {\n\tif b.AssetBuilder != nil {\n\t\treturn b.AssetBuilder, nil\n\t}\n\n\tclientset, err := b.GetClientset(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcluster, err := b.GetCluster(ctx)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/commands/toolbox_enroll.go#L646-L682","documentation":"GetCluster fetches the cluster spec from the cluster registry via clientset.GetCluster. The registry store returns (nil, nil) when no cluster object exists under b.ClusterName, and this code converts that nil result into an explicit 'cluster %q not found' error. It guards callers (GetFullCluster, GetCloud, GetInstanceGroups, GetAssetBuilder) from proceeding with a nil cluster.","triggerScenarios":"Calling any ConfigBuilder method that resolves the cluster when b.ClusterName does not exist in the state store — e.g. kops toolbox enroll against a cluster name that was never created or was deleted.","commonSituations":"Typo in --name / KOPS_CLUSTER_NAME; pointing KOPS_STATE_STORE at the wrong bucket/path; cluster deleted by another operator; state store backend misconfigured (wrong region/credentials silently listing an empty store); stale kubeconfig-style cluster name from another environment.","solutions":["Verify the exact cluster name with `kops get clusters` against the configured state store (`kops get --state <store>`).","Check KOPS_STATE_STORE / --state points at the bucket where the cluster was actually created.","Correct the --name flag (or cluster name in config) to match an existing cluster.","If the cluster is genuinely missing, create it with `kops create cluster` before enrolling."],"exampleFix":"// before\nkops toolbox enroll --name prod.example.com\n// after\nkops toolbox enroll --name prod.example.com --state s3://correct-bucket  # name verified via kops get","handlingStrategy":"validation","validationCode":"// Verify the cluster exists before running toolbox enroll\nout, err := exec.Command(\"kops\", \"get\", \"cluster\", clusterName, \"--state\", stateStore).Output()\nif err != nil {\n\treturn fmt.Errorf(\"cluster %q does not exist in state store %s\", clusterName, stateStore)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n\tif strings.Contains(err.Error(), \"not found\") {\n\t\t// prompt user to verify --name and KOPS_STATE_STORE\n\t}\n\treturn err\n}","preventionTips":["Always pass --state explicitly rather than relying on KOPS_STATE_STORE env","Copy the cluster name from `kops get` output instead of typing it","Check that the state store bucket/credentials belong to the intended environment"],"tags":["kops","cluster-registry","state-store","not-found"],"backgroundTag":"cluster-not-found","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"}