{"record":{"id":"f8b497825ef6b36b","repo":"kubernetes/kops","slug":"error-storing-instancegroup-v-f8b497","errorCode":null,"errorMessage":"error storing InstanceGroup: %v","messagePattern":"error storing InstanceGroup: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/toolbox_instance-selector.go","lineNumber":347,"sourceCode":"\t\t\tcase OutputYaml:\n\t\t\t\tif err := fullOutputYAML(out, ig); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error writing cluster yaml to stdout: %v\", err)\n\t\t\t\t}\n\t\t\tcase OutputJSON:\n\t\t\t\tif err := fullOutputJSON(out, true, ig); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error writing cluster json to stdout: %v\", err)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"unsupported output type %q\", options.Output)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\tfor _, ig := range newInstanceGroups {\n\t\t_, err = clientset.InstanceGroupsFor(cluster).Create(ctx, ig, metav1.CreateOptions{})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error storing InstanceGroup: %v\", err)\n\t\t}\n\n\t\tif err := fullOutputYAML(out, ig); err != nil {\n\t\t\treturn fmt.Errorf(\"error writing cluster yaml to stdout: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc processAndValidateFlags(commandline *cli.CommandLineInterface) error {\n\tif err := commandline.SetUntouchedFlagValuesToNil(); err != nil {\n\t\treturn err\n\t}\n\n\tif err := commandline.ProcessFlags(); err != nil {\n\t\treturn err\n\t}","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/toolbox_instance-selector.go#L329-L365","documentation":"Without --dry-run, the command creates each generated InstanceGroup via clientset.InstanceGroupsFor(cluster).Create. Any API-server rejection (auth, conflict, invalid spec, unreachable server) is wrapped as this error. The cluster itself already exists; only the InstanceGroup write failed.","triggerScenarios":"Create() returns an error: 401/403 from bad kubeconfig or RBAC, 409 AlreadyExists for a duplicate IG name, 422 validation failure of the IG spec, or connection errors to the API server.","commonSituations":"Re-running the command after a partial run (IG names already exist); stale KUBE_CONTEXT pointing at the wrong cluster; RBAC lacking create on instancegroups; running instance groups named 'nodes1' colliding with existing 'nodes1'.","solutions":["Read the wrapped cause: AlreadyExists means an IG with that name exists — use a different --name prefix or delete the old IG.","Verify kubectl auth to the cluster: `kops export kubecfg <cluster>` then `kubectl get instancegroups`.","Check RBAC allows creating instancesgroups in the cluster.","Confirm connectivity to the cluster API server (VPN/DNS) before rerunning."],"exampleFix":"// before (collision)\nkops toolbox instance-selector --name nodes ...\n// after\nkops toolbox instance-selector --name nodes2 ...\n# or delete stale group first:\nkops delete instancegroup nodes1 --yes","handlingStrategy":"validation","validationCode":"// Pre-flight: does an IG with the target name already exist?\nigs, _ := clientset.InstanceGroupsFor(cluster).List(ctx, metav1.ListOptions{})\nfor _, ig := range igs.Items {\n\tif strings.HasPrefix(ig.Name, options.InstanceGroupName) {\n\t\treturn fmt.Errorf(\"instance group %s already exists\", ig.Name)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if _, err := clientset.InstanceGroupsFor(cluster).Create(ctx, ig, metav1.CreateOptions{}); err != nil {\n\tif apierrors.IsAlreadyExists(err) {\n\t\tlog.Printf(\"IG %s exists; skipping\", ig.Name); continue\n\t}\n\treturn fmt.Errorf(\"error storing InstanceGroup: %v\", err)\n}","preventionTips":["Check for existing instance groups before running the selector.","Use unique --name prefixes per run.","Verify kubeconfig/RBAC with `kubectl auth can-i create instancegroups` first."],"tags":["kubernetes-api","instancegroup","state-conflict"],"backgroundTag":"api-server-create-failed","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"}