kubernetes/kops · error

error detatching LoadBalancers: %v

Error message

error detatching LoadBalancers: %v

What it means

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.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go:677

		if _, err := t.Cloud.Autoscaling().UpdateAutoScalingGroup(ctx, request); err != nil {
			return fmt.Errorf("error updating AutoscalingGroup: %v", err)
		}

		if deleteTagsRequest != nil && len(deleteTagsRequest.Tags) > 0 {
			if _, err := t.Cloud.Autoscaling().DeleteTags(ctx, deleteTagsRequest); err != nil {
				return fmt.Errorf("error deleting old AutoscalingGroup tags: %v", err)
			}
		}
		if updateTagsRequest != nil {
			if _, err := t.Cloud.Autoscaling().CreateOrUpdateTags(ctx, updateTagsRequest); err != nil {
				return fmt.Errorf("error updating AutoscalingGroup tags: %v", err)
			}
		}

		if detachLBRequest != nil {
			if _, err := t.Cloud.Autoscaling().DetachLoadBalancers(ctx, detachLBRequest); err != nil {
				return fmt.Errorf("error detatching LoadBalancers: %v", err)
			}
		}
		if attachLBRequest != nil {
			if _, err := t.Cloud.Autoscaling().AttachLoadBalancers(ctx, attachLBRequest); err != nil {
				return fmt.Errorf("error attaching LoadBalancers: %v", err)
			}
		}
		if len(attachTGRequests) > 0 {
			for _, attachTGRequest := range attachTGRequests {
				if _, err := t.Cloud.Autoscaling().AttachLoadBalancerTargetGroups(ctx, attachTGRequest); err != nil {
					return fmt.Errorf("failed to attach target groups: %v", err)
				}
			}
		}
	}

	return nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. 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.
  2. Verify the ELB name in the spec matches an existing ELB in the same region.
  3. Confirm IAM permissions include autoscaling:DetachLoadBalancers and elasticloadbalancing:*.
  4. Retry after backoff if throttled.
Defensive patterns

Strategy: validation

Validate before calling

// confirm ELB exists and is in the same region before detach
_, err := elbSvc.DescribeLoadBalancers(&elb.DescribeLoadBalancersInput{
  LoadBalancerNames: []string{lbName},
})
if err != nil { return fmt.Errorf("ELB %s not found; update spec", lbName) }

Try / catch

if _, err := svc.DetachLoadBalancers(ctx, req); err != nil {
  if isNotFound(err) { // already detached/removed
    klog.V(2).Infof("ELB already detached, continuing")
    return nil
  }
  return retryOrFatal(err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/8a03325d5667a8e1. Report an issue: GitHub.