{"record":{"id":"26d0ad712de9705f","repo":"kubernetes/kops","slug":"getting-cluster-q-v","errorCode":null,"errorMessage":"getting cluster: %q: %v","messagePattern":"getting cluster: %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/promote_keypair.go","lineNumber":123,"sourceCode":"\t\t\treturn completePromoteKeyset(cmd.Context(), f, options, args, toComplete)\n\t\t},\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\treturn RunPromoteKeypair(cmd.Context(), f, out, options)\n\t\t},\n\t}\n\n\treturn cmd\n}\n\n// RunPromoteKeypair promotes a keypair.\nfunc RunPromoteKeypair(ctx context.Context, f *util.Factory, out io.Writer, options *PromoteKeypairOptions) error {\n\tif !rotatableKeysetFilter(options.Keyset, nil) {\n\t\treturn fmt.Errorf(\"promoting keypairs for %q is not supported\", options.Keyset)\n\t}\n\n\tcluster, err := GetCluster(ctx, f, options.ClusterName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting cluster: %q: %v\", options.ClusterName, err)\n\t}\n\n\tclientSet, err := f.KopsClient()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting clientset: %v\", err)\n\t}\n\n\tkeyStore, err := clientSet.KeyStore(cluster)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting keystore: %v\", err)\n\t}\n\n\tif options.Keyset != \"all\" {\n\t\treturn promoteKeypair(ctx, out, options.Keyset, options.KeypairID, keyStore)\n\t}\n\n\tkeysets, err := keyStore.ListKeysets()\n\tif err != nil {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/promote_keypair.go#L105-L141","documentation":"After validating the keyset, RunPromoteKeypair calls GetCluster to fetch the cluster spec from the state store. Any failure there (cluster not found, state store unreachable, auth problems) is wrapped as \"getting cluster: %q: %v\".","triggerScenarios":"`kops promote keypair ... --name <cluster>` where the cluster does not exist in the state store, or the state store (S3/GCS/etc.) is unreachable or credentials are missing.","commonSituations":"Wrong --name (typo in cluster name); KOPS_STATE_STORE not set or pointing at a wrong/deleted bucket; expired cloud credentials; network restrictions blocking the state store.","solutions":["Verify the cluster exists: `kops get clusters` and correct --name","Check KOPS_STATE_STORE points to the correct bucket and is reachable","Refresh cloud credentials (aws s3 ls / gcloud auth) and retry","Inspect the inner %v error for the precise storage/auth cause"],"exampleFix":"// before\nkops promote keypair all  # KOPS_STATE_STORE unset\n// after\nexport KOPS_STATE_STORE=s3://my-state-bucket\nkops promote keypair all --name mycluster.k8s.local","handlingStrategy":"try-catch","validationCode":"kops get cluster \"$CLUSTER\" >/dev/null || { echo \"cluster not reachable/found\"; exit 1; }","typeGuard":null,"tryCatchPattern":"err := RunPromoteKeypair(ctx, f, out, opts)\nif err != nil && strings.Contains(err.Error(), \"getting cluster\") {\n\tlog.Printf(\"check state store & cluster name: %v\", err)\n}","preventionTips":["Confirm KOPS_STATE_STORE before running","Test with `kops get cluster <name>` first","Keep cloud credentials fresh","Use exact cluster FQDN from `kops get clusters`"],"tags":["cli","state-store","cluster-lookup","network"],"backgroundTag":"state-store-unreachable","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"}