{"record":{"id":"7ddc9d36c47e1f7a","repo":"kubernetes/kops","slug":"found-multiple-dhcpoptions-with-name-s","errorCode":null,"errorMessage":"found multiple DhcpOptions with name: %s","messagePattern":"found multiple DhcpOptions with name: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/dhcp_options.go","lineNumber":76,"sourceCode":"\n\trequest := &ec2.DescribeDhcpOptionsInput{}\n\tif e.ID != nil {\n\t\trequest.DhcpOptionsIds = []string{aws.ToString(e.ID)}\n\t} else {\n\t\trequest.Filters = cloud.BuildFilters(e.Name)\n\t}\n\n\tresponse, err := cloud.EC2().DescribeDhcpOptions(c.Context(), request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing DHCPOptions: %v\", err)\n\t}\n\n\tif response == nil || len(response.DhcpOptions) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tif len(response.DhcpOptions) != 1 {\n\t\treturn nil, fmt.Errorf(\"found multiple DhcpOptions with name: %s\", *e.Name)\n\t}\n\tklog.V(2).Info(\"found existing DhcpOptions\")\n\to := response.DhcpOptions[0]\n\tactual := &DHCPOptions{\n\t\tID:   o.DhcpOptionsId,\n\t\tName: findNameTag(o.Tags),\n\t\tTags: intersectTags(o.Tags, e.Tags),\n\t}\n\n\tfor _, s := range o.DhcpConfigurations {\n\t\tk := aws.ToString(s.Key)\n\t\tv := \"\"\n\t\tfor _, av := range s.Values {\n\t\t\tif v != \"\" {\n\t\t\t\tv = v + \",\"\n\t\t\t}\n\t\t\tv = v + *av.Value\n\t\t}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/dhcp_options.go#L58-L94","documentation":"Thrown when DescribeDhcpOptions returns more than one DHCP options set matching the task's name. Find expects a unique match for the given name tag and fails rather than reconciling an ambiguous resource.","triggerScenarios":"Two or more DHCP options sets in the VPC region carry the same Name tag value, typically from duplicate applies, out-of-band creation, or clusters created with the same name in the same account.","commonSituations":"Recreated clusters reusing a name without cleaning old DHCP options sets; manual console/Terraform-managed duplicates; missing region/account isolation in tooling.","solutions":["List options sets: aws ec2 describe-dhcp-options with tag filters to find duplicates","Delete the stale duplicate (aws ec2 delete-dhcp-options) if not attached to a VPC","Attach the correct options set to the VPC or rename the duplicate's Name tag","Ensure cluster names are unique per account/region to prevent collisions"],"exampleFix":"// before: duplicate tagged sets\naws ec2 create-dhcp-options --dhcp-configuration ... --tag-specifications 'ResourceType=dhcp-options,Tags=[{Key=Name,Value=mycluster}]'  # second time\n// after: remove the stale duplicate\naws ec2 delete-dhcp-options --dhcp-options-id dopt-STALEID","handlingStrategy":"validation","validationCode":"count=$(aws ec2 describe-dhcp-options --filters Name=tag:Name,Values=$CLUSTER_NAME --query 'DhcpOptions | length(@)')\n[ \"$count\" -le 1 ] || { echo \"Duplicate DHCP options sets found\"; exit 1; }","typeGuard":null,"tryCatchPattern":"catch (err) {\n  if (String(err).startsWith('found multiple DhcpOptions')) {\n    // delete/rename stale duplicates then retry apply\n  }\n  throw err;\n}","preventionTips":["Reuse unique cluster names per account/region","Clean up DHCP options sets when deleting clusters","Manage Name tags via a single IaC tool to avoid duplicate sets"],"tags":["aws","ec2","dhcp-options","duplicate-resource"],"backgroundTag":"duplicate-resource-found","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"}