{"record":{"id":"231338a5c10f24f3","repo":"kubernetes/kops","slug":"cluster-q-not-found-231338","errorCode":null,"errorMessage":"cluster %q not found","messagePattern":"cluster %q not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/replace.go","lineNumber":168,"sourceCode":"\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)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"error replacing cluster: %v\", err)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tcase *kopsapi.InstanceGroup:\n\t\t\t\tclusterName := v.ObjectMeta.Labels[kopsapi.LabelClusterName]\n\t\t\t\tif clusterName == \"\" {\n\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)","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/replace.go#L150-L186","documentation":"With the cluster name resolved from the label, kops calls clientset.GetCluster. If the cluster is not found in the state store, the NotFound error is converted to this explicit 'cluster %q not found' message rather than creating the group.","triggerScenarios":"Replacing an InstanceGroup whose kops.k8s.io/cluster label names a cluster that does not exist in the current state store - typical when reusing manifests across state stores or after a cluster rename/deletion.","commonSituations":"Manifest copied from another cluster; KOPS_STATE_STORE pointing at the wrong bucket; cluster deleted but instancegroup manifests retained; label contains a stale cluster DNS name.","solutions":["Verify the label value matches an existing cluster: `kops get clusters`","Correct KOPS_STATE_STORE if it points at the wrong store","Update the kops.k8s.io/cluster label to the actual target cluster name","Create the cluster first before replacing its instance groups"],"exampleFix":"// before\nlabels:\n  kops.k8s.io/cluster: old.example.com\n// after\nlabels:\n  kops.k8s.io/cluster: new.example.com","handlingStrategy":"validation","validationCode":"clusterName := ig.ObjectMeta.Labels[kopsapi.LabelClusterName]\nif _, err := clientset.GetCluster(ctx, clusterName); errors.IsNotFound(err) {\n    return fmt.Errorf(\"cluster %q does not exist in state store; create it first\", clusterName)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if errors.IsNotFound(err) {\n        // wrong label value or wrong KOPS_STATE_STORE: surface both possibilities\n        return fmt.Errorf(\"cluster %q not found; check label and KOPS_STATE_STORE\", clusterName)\n    }\n    return err\n}","preventionTips":["Cross-check the label value against `kops get clusters`","Set KOPS_STATE_STORE explicitly in automation","Create the cluster before its instance groups","Avoid reusing manifests from deleted/renamed clusters without updating labels"],"tags":["instancegroup","cluster","not-found"],"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"}