{"record":{"id":"603af533c2b6eeef","repo":"kubernetes/kops","slug":"error-replacing-instancegroup-v","errorCode":null,"errorMessage":"error replacing instanceGroup: %v","messagePattern":"error replacing instanceGroup: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/replace.go","lineNumber":194,"sourceCode":"\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 == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"must specify %q label with cluster name to replace SSHCredential\", kopsapi.LabelClusterName)\n\t\t\t\t}\n\t\t\t\tif v.Spec.PublicKey == \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"spec.PublicKey is required\")\n\t\t\t\t}\n\n\t\t\t\tcluster, err := clientset.GetCluster(ctx, clusterName)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tsshCredentialStore, err := clientset.SSHCredentialStore(cluster)\n\t\t\t\tif err != nil {","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/replace.go#L176-L212","documentation":"When the InstanceGroup exists (ig != nil), `kops replace` calls Update to persist the new version. This error wraps any failure returned by that Update call — the replacement of the existing InstanceGroup resource failed against the state store.","triggerScenarios":"Update fails: optimistic-concurrency/conflict (IG modified since last read), spec rejected by validation, or state-store write failure (network/permissions).","commonSituations":"Another operator or CI job updated the IG concurrently; manifest removes required fields or references deleted subnets/AMIs; temporary S3/etcd unavailability.","solutions":["Read the wrapped error; if it's a conflict, re-fetch the current IG (`kops get ig <name> -o yaml`) and rebase your change before replacing.","Fix any validation issues flagged in the wrapped error (e.g. subnet or instance type references).","Retry if the backend error was transient.","Ensure only one pipeline mutates the cluster at a time (locking in CI)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Compare your manifest against the live IG before update\nlive, _ := json.Marshal(liveIG)\nwanted, _ := json.Marshal(newIG)\nif !bytes.Equal(normalize(live), normalize(wanted)) { /* rebase changes */ }","typeGuard":null,"tryCatchPattern":"if strings.HasPrefix(err.Error(), \"error replacing instanceGroup:\") {\n    // fetch current IG, rebase manifest changes, retry once\n    ig, _ := clientset.InstanceGroupsFor(cluster).Get(ctx, igName, metav1.GetOptions{})\n    mergeChanges(ig, newIG)\n    return clientset.InstanceGroupsFor(cluster).Update(ctx, ig, metav1.UpdateOptions{})\n}","preventionTips":["Serialize cluster mutations through a single pipeline","Re-fetch and rebase IG manifests before each replace","Avoid editing IGs by hand while automation is running","Keep subnets/AMIs referenced by manifests valid for the cluster"],"tags":["kops","instancegroup","update","conflict"],"backgroundTag":"resource-update-conflict","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"}