{"record":{"id":"bb738787e4afaefb","repo":"kubernetes/kops","slug":"cluster-not-found-q","errorCode":null,"errorMessage":"cluster not found %q","messagePattern":"cluster not found %q","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/get_cluster.go","lineNumber":205,"sourceCode":"\tdefault:\n\t\treturn fmt.Errorf(\"unknown output format: %q\", options.Output)\n\t}\n}\n\n// filterClustersByName returns the clusters matching the specified names.\n// If names are specified and no cluster is found with a name, we return an error.\nfunc filterClustersByName(clusterNames []string, clusters []*kopsapi.Cluster) ([]*kopsapi.Cluster, error) {\n\tif len(clusterNames) != 0 {\n\t\t// Build a map as we want to return them in the same order as args\n\t\tm := make(map[string]*kopsapi.Cluster)\n\t\tfor _, c := range clusters {\n\t\t\tm[c.ObjectMeta.Name] = c\n\t\t}\n\t\tvar filtered []*kopsapi.Cluster\n\t\tfor _, clusterName := range clusterNames {\n\t\t\tc := m[clusterName]\n\t\t\tif c == nil {\n\t\t\t\treturn nil, fmt.Errorf(\"cluster not found %q\", clusterName)\n\t\t\t}\n\n\t\t\tfiltered = append(filtered, c)\n\t\t}\n\t\treturn filtered, nil\n\t}\n\n\treturn clusters, nil\n}\n\nfunc clusterOutputTable(clusters []*kopsapi.Cluster, out io.Writer) error {\n\tt := &tables.Table{}\n\tt.AddColumn(\"NAME\", func(c *kopsapi.Cluster) string {\n\t\treturn c.ObjectMeta.Name\n\t})\n\tt.AddColumn(\"CLOUD\", func(c *kopsapi.Cluster) string {\n\t\treturn string(c.GetCloudProvider())\n\t})","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/get_cluster.go#L187-L223","documentation":"When one or more cluster names are requested explicitly, filterClustersByName builds a name->cluster map and returns 'cluster not found %q' the first time a requested name has no matching cluster in the state store. Unlike the empty-list case, this pinpoints the exact missing name.","triggerScenarios":"`kops get cluster missing.example.com` where the name does not exactly match a cluster's ObjectMeta.Name in the state store.","commonSituations":"Typos in the cluster FQDN; using a short alias (e.g. 'mycluster') instead of the full DNS name; querying a state store different from the one where the cluster was created; cluster deleted by a teammate.","solutions":["Run `kops get clusters` (plural, no args) to list exact cluster names and copy the one you meant.","Use the full cluster name exactly as registered (usually the DNS FQDN), not an alias or partial name.","Confirm KOPS_STATE_STORE points at the store holding that cluster: `kops get clusters --state s3://<bucket>`.","Check `kops export kubecfg` history or the bucket for renames/deletions."],"exampleFix":"// before\nkops get cluster mycluster\n// after\nkops get cluster mycluster.example.com","handlingStrategy":"validation","validationCode":"# resolve exact cluster names first\nkops get clusters --name \"$1\" >/dev/null 2>&1 || {\n  echo \"$1 is not a cluster in $KOPS_STATE_STORE; run: kops get clusters\" >&2; exit 1\n}\nkops get cluster \"$1\"","typeGuard":"null","tryCatchPattern":"if ! kops get cluster \"$CLUSTER\" >/dev/null 2>&1; then\n  echo \"cluster '$CLUSTER' not found — exact names:\"\n  kops get clusters\nfi","preventionTips":["Always copy cluster names from `kops get clusters` output; don't type from memory.","Use full DNS names, not short aliases.","Verify the state store matches the environment that created the cluster."],"tags":["cli","cluster-name","kops-get"],"backgroundTag":"resource-not-found","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"}