{"record":{"id":"d0717a792642cb3a","repo":"kubernetes/kops","slug":"no-clusters-found","errorCode":null,"errorMessage":"no clusters found","messagePattern":"no clusters found","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/get_cluster.go","lineNumber":156,"sourceCode":"\t\t\tclusterList = append(clusterList, cluster)\n\t\t}\n\t} else {\n\t\tlist, err := client.ListClusters(ctx, metav1.ListOptions{})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor i := range list.Items {\n\t\t\tclusterList = append(clusterList, &list.Items[i])\n\t\t}\n\t}\n\n\tclusters, err := filterClustersByName(options.ClusterNames, clusterList)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(clusters) == 0 {\n\t\treturn fmt.Errorf(\"no clusters found\")\n\t}\n\n\tif options.FullSpec {\n\t\tvar err error\n\t\tclusters, err = fullClusterSpecs(ctx, client.VFSContext(), clusters)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfmt.Fprint(out, get_cluster_full_warning)\n\t}\n\n\tvar obj []runtime.Object\n\tif options.Output != OutputTable {\n\t\tfor _, c := range clusters {\n\t\t\tobj = append(obj, c)\n\t\t}\n\t}","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/get_cluster.go#L138-L174","documentation":"After listing all clusters from the state store, RunGetClusters filters them by the requested names and fails with 'no clusters found' when the resulting list is empty. This happens when no clusters exist in the state store at all, or when name filtering returned nothing without an explicit 'not found' error path. It is thrown instead of printing empty output so users get a clear signal.","triggerScenarios":"`kops get clusters` (no args, no --name) against a state store containing zero clusters, or filterClustersByName returning an empty match set in the non-strict path.","commonSituations":"Pointing KOPS_STATE_STORE at a fresh or wrong bucket (e.g. s3://bucket vs s3://bucket/prefix); typo'd state store in another account/region; clusters were deleted; running `kops get` before `kops create cluster`.","solutions":["Verify the state store: `kops get clusters --state s3://<correct-bucket>` and confirm KOPS_STATE_STORE is correct.","List the bucket contents (`aws s3 ls s3://bucket/`) to confirm cluster manifests exist under the expected path.","Create a cluster first with `kops create cluster` if none exists.","Check for state-store path prefixes — kops stores under a prefix if one was used at create time."],"exampleFix":"// before\nKOPS_STATE_STORE=s3://wrong-bucket kops get clusters\n// after\nKOPS_STATE_STORE=s3://my-kops-bucket kops get clusters","handlingStrategy":"validation","validationCode":"# precondition: state store has clusters\naws s3 ls \"${KOPS_STATE_STORE#s3://}/cluster-completed.spec\" >/dev/null 2>&1 \\\n  || aws s3 ls \"$KOPS_STATE_STORE/\" | grep -q . \\\n  || { echo \"state store empty; nothing to get\" >&2; exit 1; }","typeGuard":"null","tryCatchPattern":"if ! out=$(kops get clusters 2>&1); then\n  case \"$out\" in *\"no clusters found\"*) echo \"state store $KOPS_STATE_STORE has no clusters\";; *) echo \"$out\";; esac\nfi","preventionTips":["Pin KOPS_STATE_STORE per environment in scripts; don't rely on ambient values.","Run `kops get clusters` once at script start as a precondition check.","Use full state-store URLs including any prefix used at create time."],"tags":["cli","state-store","kops-get"],"backgroundTag":"no-resources-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"}