{"record":{"id":"1b0c82c07c51e0ff","repo":"kubernetes/kops","slug":"unable-to-check-for-instancegroup-v","errorCode":null,"errorMessage":"unable to check for instanceGroup: %v","messagePattern":"unable to check for instanceGroup: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/replace.go","lineNumber":181,"sourceCode":"\t\t\t\t\treturn fmt.Errorf(\"must specify %q label with cluster name to replace instanceGroup\", kopsapi.LabelClusterName)\n\t\t\t\t}\n\t\t\t\tcluster, err := clientset.GetCluster(ctx, clusterName)\n\t\t\t\tif err != nil {\n\t\t\t\t\tif errors.IsNotFound(err) {\n\t\t\t\t\t\treturn fmt.Errorf(\"cluster %q not found\", clusterName)\n\t\t\t\t\t}\n\t\t\t\t\treturn fmt.Errorf(\"error fetching cluster %q: %v\", clusterName, err)\n\t\t\t\t}\n\t\t\t\t// check if the instancegroup exists already\n\t\t\t\tigName := v.ObjectMeta.Name\n\t\t\t\tig, err := clientset.InstanceGroupsFor(cluster).Get(ctx, igName, metav1.GetOptions{})\n\t\t\t\tif err != nil {\n\t\t\t\t\tif errors.IsNotFound(err) {\n\t\t\t\t\t\tif !c.Force {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"instanceGroup: %v does not exist (try adding --force flag)\", igName)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn fmt.Errorf(\"unable to check for instanceGroup: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tswitch ig {\n\t\t\t\tcase nil:\n\t\t\t\t\tklog.Infof(\"instanceGroup: %v was not found, creating resource now\", igName)\n\t\t\t\t\t_, err = clientset.InstanceGroupsFor(cluster).Create(ctx, v, metav1.CreateOptions{})\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"error creating instanceGroup: %v\", err)\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\t_, err = clientset.InstanceGroupsFor(cluster).Update(ctx, v, metav1.UpdateOptions{})\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"error replacing instanceGroup: %v\", err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase *kopsapi.SSHCredential:\n\t\t\t\tclusterName := v.ObjectMeta.Labels[kopsapi.LabelClusterName]\n\t\t\t\tif clusterName == \"\" {","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/replace.go#L163-L199","documentation":"Before replacing an InstanceGroup, `kops replace` performs a Get to check whether the IG already exists. This error wraps any error from that Get call that is NOT a clean NotFound — i.e. the existence check itself failed due to a state-store/backend problem, so kOps cannot proceed safely.","triggerScenarios":"clientset.InstanceGroupsFor(cluster).Get returns a non-NotFound error: state-store backend unreachable or permission denied, malformed API response, network failure talking to the backing store (S3/GS/etcd), or invalid credentials.","commonSituations":"Expired or missing cloud credentials (AWS session, GCP tokens); wrong KOPS_STATE_STORE permissions; transient S3/OS API outages; state store bucket deleted or region misconfigured.","solutions":["Read the wrapped %v error to identify the backend failure (auth, network, permissions).","Re-run after fixing credentials: `aws s3 ls $KOPS_STATE_STORE` / equivalent to confirm access to the state store.","Check bucket name, region, and KOPS_STATE_STORE env value for typos.","Retry if the failure was transient (e.g. S3 503 slow-down)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-flight: verify state store reachability before mutating commands\nout, err := exec.Command(\"kops\", \"get\", \"clusters\").CombinedOutput()\nif err != nil {\n    return fmt.Errorf(\"state store unreachable, aborting: %v: %s\", err, out)\n}","typeGuard":null,"tryCatchPattern":"err := runReplace(...)\nif err != nil && strings.HasPrefix(err.Error(), \"unable to check for instanceGroup:\") {\n    // backend issue: refresh cloud credentials, then retry with backoff\n    refreshCloudCreds(); retryWithBackoff(runReplace)\n}","preventionTips":["Refresh AWS/GCP credentials before kops runs (aws sso login, token refresh in CI)","Validate KOPS_STATE_STORE and bucket permissions in pipeline preflight","Add retry with backoff for transient backend errors","Monitor cloud provider status for S3/GS outages"],"tags":["kops","state-store","api-error","instancegroup"],"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"}