{"record":{"id":"599d595f670c34df","repo":"kubernetes/kops","slug":"load-balancer-q-has-no-loadbalancername","errorCode":null,"errorMessage":"load balancer %q has no LoadBalancerName","messagePattern":"load balancer %q has no LoadBalancerName","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go","lineNumber":377,"sourceCode":"\t\t\tAutoScalingGroupName:             e.Name,\n\t\t\tMinSize:                          e.MinSize,\n\t\t\tMaxSize:                          e.MaxSize,\n\t\t\tNewInstancesProtectedFromScaleIn: e.InstanceProtection,\n\t\t\tTags:                             v.AutoscalingGroupTags(),\n\t\t\tVPCZoneIdentifier:                new(strings.Join(e.AutoscalingGroupSubnets(), \",\")),\n\t\t\tCapacityRebalance:                e.CapacityRebalance,\n\t\t}\n\n\t\t//On ASG creation 0 value is forbidden\n\t\tif fi.ValueOf(e.MaxInstanceLifetime) == 0 {\n\t\t\trequest.MaxInstanceLifetime = nil\n\t\t} else {\n\t\t\trequest.MaxInstanceLifetime = e.MaxInstanceLifetime\n\t\t}\n\n\t\tfor _, k := range e.LoadBalancers {\n\t\t\tif k.LoadBalancerName == nil {\n\t\t\t\treturn fmt.Errorf(\"load balancer %q has no LoadBalancerName\", fi.ValueOf(k.GetName()))\n\t\t\t}\n\t\t\trequest.LoadBalancerNames = append(request.LoadBalancerNames, aws.ToString(k.LoadBalancerName))\n\t\t}\n\n\t\tfor _, tg := range e.TargetGroups {\n\t\t\trequest.TargetGroupARNs = append(request.TargetGroupARNs, aws.ToString(tg.ARN))\n\t\t}\n\n\t\t// @check are we using mixed instances policy, or launch template\n\t\tif e.UseMixedInstancesPolicy() {\n\t\t\trequest.MixedInstancesPolicy = &autoscalingtypes.MixedInstancesPolicy{\n\t\t\t\tInstancesDistribution: &autoscalingtypes.InstancesDistribution{\n\t\t\t\t\tOnDemandAllocationStrategy:          e.MixedOnDemandAllocationStrategy,\n\t\t\t\t\tOnDemandPercentageAboveBaseCapacity: e.MixedOnDemandAboveBase,\n\t\t\t\t\tOnDemandBaseCapacity:                e.MixedOnDemandBase,\n\t\t\t\t\tSpotAllocationStrategy:              e.MixedSpotAllocationStrategy,\n\t\t\t\t\tSpotInstancePools:                   e.MixedSpotInstancePools,\n\t\t\t\t\tSpotMaxPrice:                        e.MixedSpotMaxPrice,","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go#L359-L395","documentation":"During ASG creation, each referenced LoadBalancer task must carry a concrete LoadBalancerName (set only after the ELB task has been found/created). A nil name means the load balancer task was never resolved, so the ASG cannot attach to it.","triggerScenarios":"RenderAWS builds CreateAutoScalingGroupInput with e.LoadBalancers where some element has LoadBalancerName == nil — e.g. the LB ref points to a task that was never rendered/created in this run, or spec wires a loadBalancer whose name kOps could not determine.","commonSituations":"Cluster spec references an external/incompletely-defined load balancer, or an older cluster spec where classic ELB attachment tasks were renamed/removed during upgrades.","solutions":["Ensure the loadBalancer(s) are defined as full LoadBalancer tasks in the cluster/instance-group spec so kOps resolves their names","Run `kops update cluster` (full apply, not a partial/targeted run) so the LB task renders before the ASG","If migrating between classic ELB and target-group attachments, update the spec consistently","Check for kops version mismatches between state store and CLI"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// ensure every loadBalancer referenced in instance group spec resolves to a named LB task\nfor _, ig := range instanceGroups {\n  for _, lb := range ig.Spec.LoadBalancers {\n    if lb.LoadBalancerName == nil && lb.TargetGroupARN == nil {\n      return fmt.Errorf(\"instance group %s references unresolved load balancer\", ig.Name)\n    }\n  }\n}","typeGuard":"func lbHasName(k awstasks.LoadBalancer) bool { return k.LoadBalancerName != nil }","tryCatchPattern":"null","preventionTips":["Always run full `kops update cluster` so LB tasks render before ASG tasks","Keep loadBalancer references in the cluster spec, not ad-hoc overrides","Avoid mixing classic ELB attachments with target-group attachments during migrations"],"tags":["aws","autoscaling","loadbalancer","nil-pointer"],"backgroundTag":"unresolved-task-reference","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"}