{"record":{"id":"87c57965178f0fb6","repo":"kubernetes/kops","slug":"error-fetching-cluster-q-v-87c579","errorCode":null,"errorMessage":"error fetching cluster %q: %v","messagePattern":"error fetching cluster %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/replace.go","lineNumber":135,"sourceCode":"\t\t\t\t{\n\t\t\t\t\t// Retrieve the current status of the cluster.  This will eventually be part of the cluster object.\n\t\t\t\t\tcloud, err := cloudup.BuildCloud(v)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tstatus, err := cloud.FindClusterStatus(v)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check if the cluster exists already\n\t\t\t\t\tclusterName := v.Name\n\t\t\t\t\tcluster, err := clientset.GetCluster(ctx, clusterName)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tif errors.IsNotFound(err) {\n\t\t\t\t\t\t\tcluster = nil\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"error fetching cluster %q: %v\", clusterName, err)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif cluster == nil {\n\t\t\t\t\t\tif !c.Force {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"cluster %v does not exist (try adding --force flag)\", clusterName)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\terr = cloudup.PerformAssignments(v, vfsContext, cloud)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"error populating configuration: %w\", err)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t_, err = clientset.CreateCluster(ctx, v)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"error creating cluster: %v\", err)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t_, err = clientset.UpdateCluster(ctx, v, status)","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/replace.go#L117-L153","documentation":"When replacing a Cluster manifest, kops calls clientset.GetCluster to check whether the cluster exists in the state store. If the lookup fails with anything other than NotFound (which is treated as 'does not exist'), the failure is wrapped in this error.","triggerScenarios":"State store unreachable or misconfigured (--state / KOPS_STATE_STORE pointing at a nonexistent bucket), credentials lacking permission to read the state store, network timeout to the backend, or corrupted state-store entry for the cluster name.","commonSituations":"Wrong KOPS_STATE_STORE env var (e.g. pointing at another team's bucket); IAM/S3 permission revoked; offline/blocked network in CI; cluster name in the manifest differs from what you expected and the state store backend errors.","solutions":["Check KOPS_STATE_STORE / --state points at the correct, existing bucket/container","Verify cloud credentials and read permissions on the state store (`kops get clusters` as a smoke test)","Test network connectivity/DNS to the state store backend","Inspect the wrapped underlying error (%v) for the exact backend failure","If the cluster truly should not exist, confirm the name in the manifest is correct"],"exampleFix":"// before\nexport KOPS_STATE_STORE=s3://wrong-bucket\n// after\nexport KOPS_STATE_STORE=s3://my-clusters-state-store","handlingStrategy":"try-catch","validationCode":"// smoke-test the state store first\nif err := exec.Command(\"kops\", \"get\", \"clusters\").Run(); err != nil {\n    return fmt.Errorf(\"state store unreachable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if !errors.IsNotFound(err) {\n        // backend failure, not absence: check state store config/credentials\n        log.Printf(\"GetCluster(%s) backend error: %v\", clusterName, err)\n    }\n    return err\n}","preventionTips":["Pin KOPS_STATE_STORE in scripts and verify with kops get","Grant least-privilege read access to the state store for CI roles","Monitor state-store bucket availability/permissions","Keep cluster names consistent across tooling"],"tags":["state-store","aws","cli"],"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-12T07:17:12.445Z"}