{"record":{"id":"ef5e7213e7508322","repo":"kubernetes/kops","slug":"found-multiple-instance-groups-matching-mig-q","errorCode":null,"errorMessage":"found multiple instance groups matching MIG %q","messagePattern":"found multiple instance groups matching MIG %q","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gce/instancegroups.go","lineNumber":296,"sourceCode":"\treturn s\n}\n\n// matchInstanceGroup filters a list of instancegroups for recognized cloud groups\nfunc matchInstanceGroup(mig *compute.InstanceGroupManager, c *kops.Cluster, instancegroups []*kops.InstanceGroup) (*kops.InstanceGroup, error) {\n\tmigName := LastComponent(mig.Name)\n\tvar matches []*kops.InstanceGroup\n\tfor _, ig := range instancegroups {\n\t\tname := NameForInstanceGroupManager(c.ObjectMeta.Name, ig.ObjectMeta.Name, LastComponent(mig.Zone))\n\t\tif name == migName {\n\t\t\tmatches = append(matches, ig)\n\t\t}\n\t}\n\n\tif len(matches) == 0 {\n\t\treturn nil, nil\n\t}\n\tif len(matches) != 1 {\n\t\treturn nil, fmt.Errorf(\"found multiple instance groups matching MIG %q\", mig.Name)\n\t}\n\treturn matches[0], nil\n}\n\nfunc addCloudInstanceData(cm *cloudinstances.CloudInstance, instance *compute.Instance) {\n\tcm.MachineType = LastComponent(instance.MachineType)\n\tcm.Status = instance.Status\n\tif instance.Status == \"RUNNING\" {\n\t\tcm.State = cloudinstances.CloudInstanceStatusUpToDate\n\t}\n\tfor k := range instance.Labels {\n\t\tif !strings.HasPrefix(k, GceLabelNameRolePrefix) {\n\t\t\tcontinue\n\t\t}\n\t\trole := strings.TrimPrefix(k, GceLabelNameRolePrefix)\n\t\t// A VM must have one network interface and at most a single AccessConfig on an network interface\n\t\t// Also kops doesn't support MultiNics\n\t\tcm.PrivateIP = fi.ValueOf(&instance.NetworkInterfaces[0].NetworkIP)","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gce/instancegroups.go#L278-L314","documentation":"Returned by matchInstanceGroup when more than one kops InstanceGroup in the cluster spec matches the same GCE managed instance group, making the mapping ambiguous. GetCloudGroups cannot tell which kops instance group owns the MIG, so it fails rather than guess. This reflects inconsistent or duplicated cluster configuration.","triggerScenarios":"Calling GetCloudGroups (indirectly via rolling-update, get, etc.) when the cluster spec contains two or more InstanceGroups whose names/tags both match mig.Name — e.g. duplicated group names, a MIG matching multiple groups by shared label/tag, or a copied instance group spec not fully renamed.","commonSituations":"Copy-pasting an instance group in the cluster spec and changing only some fields, exporting/re-importing cluster manifests producing duplicates, or MIGs with overly generic tags matching several groups.","solutions":["Dump the cluster spec (kops get ig <cluster> -o yaml) and remove/merge duplicate instance group entries.","Ensure each kops InstanceGroup has a unique name; rename the copied one and re-apply (kops update cluster).","Verify the MIG's kops-managed labels/name correspond to exactly one instance group; fix stale labels in GCP if edited manually.","Re-run kops update cluster to reconcile the MIGs with the corrected spec, then retry the operation."],"exampleFix":"// before (cluster spec)\nmetadata:\n  name: nodes-a\n  name: nodes-a   # duplicate\n// after\nmetadata:\n  name: nodes-a\nmetadata:\n  name: nodes-b","handlingStrategy":"validation","validationCode":"// pre-flight: assert every kops instance group name is unique and each MIG maps to exactly one group\nnames := map[string]int{}\nfor _, ig := range instancegroups {\n    names[ig.ObjectMeta.Name]++\n}\nfor name, n := range names {\n    if n > 1 {\n        log.Fatalf(\"instance group %q defined %d times in cluster spec\", name, n)\n    }\n}","typeGuard":"func hasUniqueInstanceGroupNames(igs []*kops.InstanceGroup) bool {\n    seen := map[string]bool{}\n    for _, ig := range igs {\n        if seen[ig.ObjectMeta.Name] {\n            return false\n        }\n        seen[ig.ObjectMeta.Name] = true\n    }\n    return true\n}","tryCatchPattern":"cloudGroups, err := gceCloud.GetCloudGroups(ctx, cluster, warnUnmatched, instancegroups)\nif err != nil {\n    if strings.Contains(err.Error(), \"found multiple instance groups matching MIG\") {\n        log.Warn(\"duplicate kops instance groups match one MIG; deduplicate the cluster spec (kops get ig -o yaml) and re-apply\")\n    }\n    return err\n}","preventionTips":["Keep instance group names unique in the cluster spec; never duplicate a group without renaming it.","Run `kops get ig -o yaml` and diff against your source manifests before updates.","Store cluster specs in version control so duplicate copies are caught in review.","Let kops create/manage all MIGs; manual console edits can introduce ambiguous matches."],"tags":["gce","gcp","instance-group","configuration","kops"],"backgroundTag":"ambiguous-instance-group-match","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}