kubernetes/kops · error

error deleting LoadBalancer %q: %v

Error message

error deleting LoadBalancer %q: %v

What it means

DeleteELB wraps a failed AWS ELB (classic) DeleteLoadBalancer call. kOps surfaces the underlying AWS API error with the LoadBalancer name for context. It is thrown whenever the deletion API returns any error other than a dependency violation (which is returned unwrapped for the retry logic in the resource tracker).

Source

Thrown at pkg/resources/aws/aws.go:1466

	return nil
}

func DeleteELB(cloud fi.Cloud, r *resources.Resource) error {
	ctx := context.TODO()
	c := cloud.(awsup.AWSCloud)

	id := r.ID

	klog.V(2).Infof("Deleting ELB %q", id)
	request := &elb.DeleteLoadBalancerInput{
		LoadBalancerName: &id,
	}
	_, err := c.ELB().DeleteLoadBalancer(ctx, request)
	if err != nil {
		if IsDependencyViolation(err) {
			return err
		}
		return fmt.Errorf("error deleting LoadBalancer %q: %v", id, err)
	}
	return nil
}

func DeleteELBV2(cloud fi.Cloud, r *resources.Resource) error {
	ctx := context.TODO()
	c := cloud.(awsup.AWSCloud)
	id := r.ID

	klog.V(2).Infof("Deleting ELBV2 %q", id)
	request := &elbv2.DeleteLoadBalancerInput{
		LoadBalancerArn: aws.String(id),
	}
	_, err := c.ELBV2().DeleteLoadBalancer(ctx, request)
	if err != nil {
		if IsDependencyViolation(err) {
			return err
		}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Re-run the delete operation; ELB deletion errors during teardown are often transient (throttling/rate limits) and resource deletion is resumable.
  2. Check IAM permissions for the caller include elasticloadbalancing:DeleteLoadBalancer on the ELB ARNs.
  3. Verify the ELB still exists (aws elb describe-load-balancers) — if already gone, kOps can proceed on the next pass.
  4. If IsDependencyViolation, remove dependent resources (e.g. targets/listeners/Route53 records) first; that path returns the raw error instead.
  5. Reduce concurrency or retry later to avoid AWS throttling.
Defensive patterns

Strategy: try-catch

Validate before calling

// Check the ELB still exists and caller has permission before deleting
out, err := c.ELB().DescribeLoadBalancers(ctx, &elb.DescribeLoadBalancersInput{
    LoadBalancerNames: []string{id},
})
if err != nil || len(out.LoadBalancerDescriptions) == 0 { /* already gone; skip */ }

Try / catch

err := DeleteELB(cloud, r)
if err != nil {
    if awsup.AWSErrorCode(err) == "ThrottlingException" {
        time.Sleep(backoff); return retry()
    }
    return fmt.Errorf("elb %s not deleted, will retry on next pass: %w", id, err)
}

Prevention

When it happens

Trigger: AWS DeleteLoadBalancer returns an error: e.g. ThrottledException, LoadBalancerNotFound on race, AccessDenied, or a transient 5xx during 'kops delete cluster' cleanup of a classic ELB.

Common situations: Deleting a cluster whose API/NLB-era ELBs were already partially removed by another operator; IAM policies lacking elasticloadbalancing:DeleteLoadBalancer; AWS API throttling during large cluster teardowns.

Related errors


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