{"record":{"id":"5ac1faa2f9bbb527","repo":"kubernetes/kops","slug":"spotinst-load-balancer-q-has-no-loadbalancername","errorCode":null,"errorMessage":"spotinst: load balancer %q has no LoadBalancerName","messagePattern":"spotinst: load balancer %q has no LoadBalancerName","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go","lineNumber":1752,"sourceCode":"}\n\nfunc (e *Elastigroup) buildAutoScaleLabels(labelsMap map[string]string) []*aws.AutoScaleLabel {\n\tlabels := make([]*aws.AutoScaleLabel, 0, len(labelsMap))\n\tfor key, value := range labelsMap {\n\t\tlabels = append(labels, &aws.AutoScaleLabel{\n\t\t\tKey:   new(key),\n\t\t\tValue: new(value),\n\t\t})\n\t}\n\n\treturn labels\n}\n\nfunc (e *Elastigroup) buildLoadBalancers(cloud awsup.AWSCloud) ([]*aws.LoadBalancer, error) {\n\tlbs := make([]*aws.LoadBalancer, len(e.LoadBalancers))\n\tfor i, lb := range e.LoadBalancers {\n\t\tif lb.LoadBalancerName == nil {\n\t\t\treturn nil, fmt.Errorf(\"spotinst: load balancer %q has no LoadBalancerName\", fi.ValueOf(lb.GetName()))\n\t\t}\n\t\tlbs[i] = &aws.LoadBalancer{\n\t\t\tType: new(\"CLASSIC\"),\n\t\t\tName: lb.LoadBalancerName,\n\t\t}\n\t}\n\treturn lbs, nil\n}\n\nfunc (e *Elastigroup) buildTargetGroups() []*aws.LoadBalancer {\n\ttgs := make([]*aws.LoadBalancer, len(e.TargetGroups))\n\tfor i, tg := range e.TargetGroups {\n\t\ttgs[i] = &aws.LoadBalancer{\n\t\t\tType: new(\"TARGET_GROUP\"),\n\t\t\tArn:  tg.ARN,\n\t\t}\n\t}\n\treturn tgs","sourceCodeStart":1734,"sourceCodeEnd":1770,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go#L1734-L1770","documentation":"buildLoadBalancers converts the task's LoadBalancers into spotinst aws.LoadBalancer objects of type CLASSIC, which require a LoadBalancerName. If a configured load balancer has only an ARN/ID and no name, kOps cannot build the CLASSIC LB reference and fails with the LB's name field (which is itself empty in practice).","triggerScenarios":"Elastigroup spec includes a load balancer entry whose LoadBalancerName is nil — e.g. the spec referenced a target-group/ALB-style attachment without a classic LB name — and buildLoadBalancers runs during terraform-value rendering or group construction.","commonSituations":"Attaching an ALB/NLB or target group to a spotinst elastigroup spec that only supports CLASSIC LBs by name; load balancer name lost when copying specs between clusters; older spec format migrations.","solutions":["Set loadBalancerName on each attached load balancer in the cluster/instance-group spec, using the classic ELB's name.","If the intent was ALB/NLB attachment, verify your kOps/spotinst task version supports it and use the appropriate field instead of the classic-LB path.","Run `kops get cluster -o yaml`, locate the loadBalancers entries for the elastigroup, and fill the missing name before applying.","Confirm the referenced classic ELB exists in the cluster region."],"exampleFix":"// before\nloadBalancers:\n- targetGroupArn: arn:aws:elasticloadbalancing:...\n// after (classic LB requires a name)\nloadBalancers:\n- loadBalancerName: my-api-elb","handlingStrategy":"validation","validationCode":"// reject LB entries without a classic LB name before building\nfor i, lb := range e.LoadBalancers {\n    if lb.LoadBalancerName == nil || *lb.LoadBalancerName == \"\" {\n        return fmt.Errorf(\"loadBalancers[%d]: loadBalancerName is required for classic ELB attachment\", i)\n    }\n}","typeGuard":"func hasLBName(lb *LoadBalancer) bool {\n    return lb != nil && lb.LoadBalancerName != nil && *lb.LoadBalancerName != \"\"\n}","tryCatchPattern":"lb, err := buildLoadBalancers(cloud)\nif err != nil {\n    return fmt.Errorf(\"skipping elastigroup render: %v\", err) // fix spec and re-apply\n}","preventionTips":["Always set loadBalancerName for classic ELB attachments in specs","Don't use the classic-LB field for ALB/NLB or target groups","Validate `kops get cluster -o yaml` loadBalancers entries before apply","Confirm the ELB name exists in the cluster region"],"tags":["spotinst","aws","load-balancer","validation"],"backgroundTag":"missing-required-argument","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"}