{"record":{"id":"62937e55d5195086","repo":"kubernetes/kops","slug":"found-multiple-nlbs-with-dnsname-q","errorCode":null,"errorMessage":"Found multiple NLBs with DNSName %q","messagePattern":"Found multiple NLBs with DNSName %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/network_load_balancer.go","lineNumber":136,"sourceCode":"\tfound, err := describeNetworkLoadBalancers(ctx, cloud, request, func(lb elbv2types.LoadBalancer) bool {\n\t\tif matchHostedZoneId != aws.ToString(lb.CanonicalHostedZoneId) {\n\t\t\treturn false\n\t\t}\n\n\t\tlbDnsName := aws.ToString(lb.DNSName)\n\t\tlbDnsName = strings.TrimSuffix(lbDnsName, \".\")\n\t\treturn lbDnsName == matchDnsName || \"dualstack.\"+lbDnsName == matchDnsName\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing NLBs: %v\", err)\n\t}\n\n\tif len(found) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tif len(found) != 1 {\n\t\treturn nil, fmt.Errorf(\"Found multiple NLBs with DNSName %q\", dnsName)\n\t}\n\n\treturn &found[0], nil\n}\n\nfunc describeNetworkLoadBalancers(ctx context.Context, cloud awsup.AWSCloud, request *elbv2.DescribeLoadBalancersInput, filter func(elbv2types.LoadBalancer) bool) ([]elbv2types.LoadBalancer, error) {\n\tvar found []elbv2types.LoadBalancer\n\tpaginator := elbv2.NewDescribeLoadBalancersPaginator(cloud.ELBV2(), request)\n\tfor paginator.HasMorePages() {\n\t\tpage, err := paginator.NextPage(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"listing NLBs: %v\", err)\n\t\t}\n\t\tfor _, lb := range page.LoadBalancers {\n\t\t\tif filter(lb) {\n\t\t\t\tfound = append(found, lb)\n\t\t\t}\n\t\t}","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/network_load_balancer.go#L118-L154","documentation":"When more than one NLB matches the alias's DNS name, kOps cannot determine which load balancer the alias targets and returns \"Found multiple NLBs with DNSName %q\". The lookup deliberately refuses to guess among ambiguous matches.","triggerScenarios":"findNetworkLoadBalancerByAlias's filter (DNSName equal or dualstack.-prefixed match) matched 2+ NLBs from DescribeLoadBalancers while resolving a Route53 alias target.","commonSituations":"Duplicate NLBs created by repeated applies or leftover clusters sharing a DNS name; a dualstack and a regular NLB both matching; stale NLBs from a previous kOps version.","solutions":["List NLBs in the region (aws elbv2 describe-load-balancers) and delete the stale duplicate","Ensure only one NLB carries the DNS name the alias points to","Re-run kops update after cleanup"],"exampleFix":"// shell before\naws elbv2 describe-load-balancers # shows two NLBs with same DNS\n// after\naws elbv2 delete-load-balancer --load-balancer-arn <stale-arn>","handlingStrategy":"validation","validationCode":"// before applying, ensure uniqueness of NLBs by DNS name\nlbs, _ := cloud.ELBV2().DescribeLoadBalancers(ctx, &elbv2.DescribeLoadBalancersInput{})\ncounts := map[string]int{}\nfor _, lb := range lbs.LoadBalancers { counts[aws.ToString(lb.DNSName)]++ }\nfor dns, n := range counts { if n > 1 { return fmt.Errorf(\"duplicate NLBs for %s; clean up first\", dns) } }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Delete stale/duplicate NLBs left by failed applies","Don't reuse cluster DNS names across clusters","Periodically audit ELBs in the account"],"tags":["aws","nlb","dns","ambiguity"],"backgroundTag":"multiple-load-balancers-match","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"}