{"record":{"id":"86f3f0fe9db6deb5","repo":"kubernetes/kops","slug":"dnsname-not-set-on-aliastarget","errorCode":null,"errorMessage":"DNSName not set on AliasTarget","messagePattern":"DNSName not set on AliasTarget","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/network_load_balancer.go","lineNumber":113,"sourceCode":"\nvar _ fi.CompareWithID = (*NetworkLoadBalancer)(nil)\nvar _ fi.CloudupTaskNormalize = (*NetworkLoadBalancer)(nil)\nvar _ fi.CloudupProducesDeletions = (*NetworkLoadBalancer)(nil)\n\nfunc (e *NetworkLoadBalancer) CompareWithID() *string {\n\treturn e.Name\n}\n\nfunc findNetworkLoadBalancerByAlias(cloud awsup.AWSCloud, alias *route53types.AliasTarget) (*elbv2types.LoadBalancer, error) {\n\tctx := context.TODO()\n\n\t// TODO: Any way to avoid listing all NLBs?\n\trequest := &elbv2.DescribeLoadBalancersInput{}\n\n\tdnsName := aws.ToString(alias.DNSName)\n\tmatchDnsName := strings.TrimSuffix(dnsName, \".\")\n\tif matchDnsName == \"\" {\n\t\treturn nil, fmt.Errorf(\"DNSName not set on AliasTarget\")\n\t}\n\n\tmatchHostedZoneId := aws.ToString(alias.HostedZoneId)\n\n\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 {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/network_load_balancer.go#L95-L131","documentation":"findNetworkLoadBalancerByAlias matches an ELBv2 Alias target (e.g. from a Route53 record) against existing NLBs by DNS name. If alias.DNSName is empty after trimming a trailing dot, the function cannot match anything and returns \"DNSName not set on AliasTarget\".","triggerScenarios":"Called from findDNSTargetNLB when a Route53 A/AAAA alias record's AliasTarget has a nil or empty DNSName field while kOps tries to determine whether the record already points at an NLB.","commonSituations":"Corrupt or manually edited Route53 alias record; record built programmatically with DNSName omitted; AWS SDK change exposing nil DNSName on an alias target.","solutions":["Inspect the Route53 record and set the correct AliasTarget DNSName (the NLB's dns name)","If the record is broken/unwanted, delete or recreate the alias record with a valid target","Re-run kops update once the alias record carries a DNSName"],"exampleFix":"// before (alias target)\n{ HostedZoneId: \"Z...\" } // DNSName missing\n// after\n{ HostedZoneId: \"Z...\", DNSName: \"k8s-elb-xxx.elb.us-east-1.amazonaws.com\" }","handlingStrategy":"validation","validationCode":"if alias != nil && (alias.DNSName == nil || strings.TrimSuffix(aws.ToString(alias.DNSName), \".\") == \"\") {\n    return fmt.Errorf(\"route53 alias target has no DNSName; fix the record before update\")\n}","typeGuard":"func aliasHasDNSName(a *route53types.AliasTarget) bool {\n    return a != nil && strings.TrimSuffix(aws.ToString(a.DNSName), \".\") != \"\"\n}","tryCatchPattern":null,"preventionTips":["Inspect Route53 alias records before applying cluster changes","Never create alias records programmatically without DNSName","Audit manually edited DNS records in the cluster hosted zone"],"tags":["aws","nlb","route53","alias"],"backgroundTag":"alias-target-dnsname-missing","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"}