kubernetes/kops · error

error deleting ELB LoadBalancer %q: %w

Error message

error deleting ELB LoadBalancer %q: %w

What it means

This error wraps a failure from the ELBV2 DeleteLoadBalancer API call made by deleteNLB.Delete. The NLB identified by its ARN could not be deleted, and the AWS API error is wrapped with %w so errors.As/Is can inspect it.

Source

Thrown at upup/pkg/fi/cloudup/awstasks/network_load_balancer.go:733

	obj *awsup.LoadBalancerInfo
}

var _ fi.CloudupDeletion = (*deleteNLB)(nil)

func (d *deleteNLB) Delete(t fi.CloudupTarget) error {
	ctx := context.TODO()

	awsTarget, ok := t.(*awsup.AWSAPITarget)
	if !ok {
		return fmt.Errorf("unexpected target type for deletion: %T", t)
	}

	arn := d.obj.ARN()
	klog.V(2).Infof("deleting load balancer %q", arn)
	if _, err := awsTarget.Cloud.ELBV2().DeleteLoadBalancer(ctx, &elbv2.DeleteLoadBalancerInput{
		LoadBalancerArn: &arn,
	}); err != nil {
		return fmt.Errorf("error deleting ELB LoadBalancer %q: %w", arn, err)
	}

	return nil
}

// String returns a string representation of the task
func (d *deleteNLB) String() string {
	return d.TaskName() + "-" + d.Item()
}

// TaskName returns the task name
func (d *deleteNLB) TaskName() string {
	return "network-load-balancer"
}

// Item returns the launch template name
func (d *deleteNLB) Item() string {
	return d.obj.ARN()

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check the wrapped AWS error: LoadBalancerNotFound usually means it's already gone (safe to proceed)
  2. Verify IAM permissions include elasticloadbalancing:DeleteLoadBalancer
  3. Retry after transient failures; if the ARN is stale, refresh kops state
  4. Manually confirm the NLB's status in the AWS console if deletion is stuck

Example fix

// before: treating not-found as fatal
return fmt.Errorf("error deleting ELB LoadBalancer %q: %w", arn, err)
// after: tolerate already-deleted
var nf *elbv2types.LoadBalancerNotFoundException
if errors.As(err, &nf) { return nil }
return fmt.Errorf("error deleting ELB LoadBalancer %q: %w", arn, err)
Defensive patterns

Strategy: retry

Validate before calling

// pre-check existence to avoid fatal not-found
_, err := awsTarget.Cloud.ELBV2().DescribeLoadBalancers(&elbv2.DescribeLoadBalancersInput{LoadBalancerArns: []string{arn}})
if isNotFound(err) { return nil } // already deleted

Try / catch

if _, err := awsTarget.Cloud.ELBV2().DeleteLoadBalancer(ctx, input); err != nil {
  var nf *elbv2types.LoadBalancerNotFoundException
  if errors.As(err, &nf) { return nil }
  if isThrottling(err) { /* retry with backoff */ }
  return fmt.Errorf("error deleting ELB LoadBalancer %q: %w", arn, err)
}

Prevention

When it happens

Trigger: DeleteLoadBalancer fails because the ARN doesn't exist (already deleted), the caller lacks elasticloadbalancing:DeleteLoadBalancer IAM permission, the NLB is in a transient state, or throttling/network errors occur.

Common situations: Destroying a cluster where the NLB was already deleted manually; IAM policies missing ELBv2 delete permissions; retry loops hitting LoadBalancerNotFound — which may be safe to ignore on teardown.

Related errors


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