{"record":{"id":"338e1af938f06e6b","repo":"kubernetes/kops","slug":"found-multiple-instance-groups-matching-asg-q","errorCode":null,"errorMessage":"found multiple instance groups matching ASG %q","messagePattern":"found multiple instance groups matching ASG %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awsup/instancegroups.go","lineNumber":47,"sourceCode":"\tfor _, g := range instancegroups {\n\t\tvar groupName string\n\t\tswitch {\n\t\tcase g.Spec.Role.HasControlPlane():\n\t\t\tgroupName = g.ObjectMeta.Name + \".masters.\" + clusterName\n\t\tcase g.Spec.Role.HasAPIServer():\n\t\t\tgroupName = g.ObjectMeta.Name + \".apiservers.\" + clusterName\n\t\tcase g.Spec.Role.HasNode():\n\t\t\tgroupName = g.ObjectMeta.Name + \".\" + clusterName\n\t\tcase g.Spec.Role.HasBastion():\n\t\t\tgroupName = g.ObjectMeta.Name + \".\" + clusterName\n\t\tdefault:\n\t\t\tklog.Warningf(\"Ignoring InstanceGroup of unknown role %q\", g.Spec.Role)\n\t\t\tcontinue\n\t\t}\n\n\t\tif name == groupName {\n\t\t\tif instancegroup != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"found multiple instance groups matching ASG %q\", groupName)\n\t\t\t}\n\t\t\tinstancegroup = g\n\t\t}\n\t}\n\n\treturn instancegroup, nil\n}\n","sourceCodeStart":29,"sourceCodeEnd":55,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awsup/instancegroups.go#L29-L55","documentation":"matchInstanceGroup matches an ASG name to a kOps InstanceGroup by comparing names. If more than one InstanceGroup in the cluster has the same name as the ASG's matching group, this error is returned because the mapping would be ambiguous. InstanceGroup names are expected to be unique within a cluster.","triggerScenarios":"Two or more InstanceGroups in the cluster spec share the same name while getCloudGroups enumerates cloud groups; the ASG name equals that duplicated InstanceGroup name.","commonSituations":"Hand-edited cluster specs where a node group was cloned (e.g. 'nodes' and 'nodes' instead of 'nodes-a'/'nodes-b'); tooling that duplicates instance groups without renaming; merges of cluster spec changes introducing duplicates.","solutions":["Run `kops get instancegroups --name <cluster>` and find the duplicate InstanceGroup name.","Rename one of the duplicate InstanceGroups to a unique name (e.g. nodes-a, nodes-b) with `kops edit instancegroup`.","Apply the updated spec (`kops update cluster`) so cloud resources and specs agree.","If intentional, ensure the ASG being matched corresponds to the renamed group."],"exampleFix":"// before (cluster.yaml, two groups both named nodes)\nmetadata:\n  name: nodes\n// after\nmetadata:\n  name: nodes-a\n# and the second group: name: nodes-b","handlingStrategy":"validation","validationCode":"names := map[string]int{}\nfor _, ig := range cluster.Spec.InstanceGroups {\n\tnames[*ig.ObjectMeta.Name]++\n}\nfor n, c := range names {\n\tif c > 1 { return fmt.Errorf(\"duplicate instance group name: %s\", n) }\n}","typeGuard":null,"tryCatchPattern":"ig, err := matchInstanceGroup(list, asgName)\nif err != nil {\n\treturn fmt.Errorf(\"cannot map ASG %q to instance group: %w\", asgName, err)\n}","preventionTips":["Enforce unique InstanceGroup names when generating specs with tooling","When cloning a node group, rename it before kops update","Run `kops get instancegroups` to audit names after manual spec edits"],"tags":["kops","instancegroup","asg","naming-conflict"],"backgroundTag":"duplicate-resource-name","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"}