{"record":{"id":"8a03325d5667a8e1","repo":"kubernetes/kops","slug":"error-detatching-loadbalancers-v","errorCode":null,"errorMessage":"error detatching LoadBalancers: %v","messagePattern":"error detatching LoadBalancers: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go","lineNumber":677,"sourceCode":"\n\t\tif _, err := t.Cloud.Autoscaling().UpdateAutoScalingGroup(ctx, request); err != nil {\n\t\t\treturn fmt.Errorf(\"error updating AutoscalingGroup: %v\", err)\n\t\t}\n\n\t\tif deleteTagsRequest != nil && len(deleteTagsRequest.Tags) > 0 {\n\t\t\tif _, err := t.Cloud.Autoscaling().DeleteTags(ctx, deleteTagsRequest); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error deleting old AutoscalingGroup tags: %v\", err)\n\t\t\t}\n\t\t}\n\t\tif updateTagsRequest != nil {\n\t\t\tif _, err := t.Cloud.Autoscaling().CreateOrUpdateTags(ctx, updateTagsRequest); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error updating AutoscalingGroup tags: %v\", err)\n\t\t\t}\n\t\t}\n\n\t\tif detachLBRequest != nil {\n\t\t\tif _, err := t.Cloud.Autoscaling().DetachLoadBalancers(ctx, detachLBRequest); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error detatching LoadBalancers: %v\", err)\n\t\t\t}\n\t\t}\n\t\tif attachLBRequest != nil {\n\t\t\tif _, err := t.Cloud.Autoscaling().AttachLoadBalancers(ctx, attachLBRequest); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error attaching LoadBalancers: %v\", err)\n\t\t\t}\n\t\t}\n\t\tif len(attachTGRequests) > 0 {\n\t\t\tfor _, attachTGRequest := range attachTGRequests {\n\t\t\t\tif _, err := t.Cloud.Autoscaling().AttachLoadBalancerTargetGroups(ctx, attachTGRequest); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to attach target groups: %v\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}","sourceCodeStart":659,"sourceCodeEnd":695,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go#L659-L695","documentation":"DetachLoadBalancers failed while removing classic ELBs the ASG should no longer reference; the ASG update itself already succeeded, but the LB detachment did not — the wrapped error is the AWS autoscaling API response.","triggerScenarios":"During ASG update, detachLBRequest is built (load balancers in the ASG spec are being removed) and Autoscaling().DetachLoadBalancers fails: the ELB no longer exists (deleted out-of-band), ASG/ELB region mismatch, throttling, or missing autoscaling:DetachLoadBalancers permission.","commonSituations":"Migrating from classic LB to target-group-based load balancing: the old ELB was already deleted in AWS; typos in loadBalancer names; credentials lacking permissions.","solutions":["If the wrapped error says the load balancer does not exist, delete it from the cluster spec / re-run `kops update cluster` so kops stops referencing it.","Verify the ELB name in the spec matches an existing ELB in the same region.","Confirm IAM permissions include autoscaling:DetachLoadBalancers and elasticloadbalancing:*.","Retry after backoff if throttled."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// confirm ELB exists and is in the same region before detach\n_, err := elbSvc.DescribeLoadBalancers(&elb.DescribeLoadBalancersInput{\n  LoadBalancerNames: []string{lbName},\n})\nif err != nil { return fmt.Errorf(\"ELB %s not found; update spec\", lbName) }","typeGuard":null,"tryCatchPattern":"if _, err := svc.DetachLoadBalancers(ctx, req); err != nil {\n  if isNotFound(err) { // already detached/removed\n    klog.V(2).Infof(\"ELB already detached, continuing\")\n    return nil\n  }\n  return retryOrFatal(err)\n}","preventionTips":["Don't delete ELBs out-of-band while kops manages the attachment.","When migrating to target groups, remove the classic LB attachment from the spec first, then delete the ELB.","Use one region consistently in the kops config."],"tags":["aws","autoscaling","load-balancer","cloud-api"],"backgroundTag":"aws-api-call-failed","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"}