kubernetes/kops · error

error deleting V2 LoadBalancer %q: %v

Error message

error deleting V2 LoadBalancer %q: %v

What it means

DeleteELBV2 wraps a failed ELBV2 (ALB/NLB) DeleteLoadBalancer API call, formatting the AWS error with the load balancer ARN. Dependency-violation errors are propagated unwrapped so the tracker can retry.

Source

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

	}
	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
		}
		return fmt.Errorf("error deleting V2 LoadBalancer %q: %v", id, err)
	}
	return nil
}

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

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

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Retry the operation — transient throttling or racing deletions usually resolve on a subsequent pass.
  2. Confirm the ALB/NLB ARN still exists; if already deleted, continue and let kOps mark it gone.
  3. Check IAM policy grants elasticloadbalancing:DeleteLoadBalancer for the ARN pattern of the ALB/NLB.
  4. If a dependency violation is reported, first delete listeners/target groups or other attached resources.
  5. Investigate the wrapped %v detail from the AWS SDK for the exact AWS error code.
Defensive patterns

Strategy: try-catch

Validate before calling

out, err := c.ELBV2().DescribeLoadBalancers(ctx, &elbv2.DescribeLoadBalancersInput{
    LoadBalancerArns: []string{id},
})
if err != nil || len(out.LoadBalancers) == 0 { /* already deleted; skip */ }

Try / catch

if err := DeleteELBV2(cloud, r); err != nil {
    code := awsup.AWSErrorCode(errors.Unwrap(err))
    if code == "ThrottlingException" { backoff-and-retry }
    else { record for next reconciliation pass }
}

Prevention

When it happens

Trigger: ELBV2 DeleteLoadBalancer fails with errors such as AccessDenied, ThrottlingException, LoadBalancerNotFound (already deleted externally), or AuthFailure/invalid ARN during cluster resource teardown.

Common situations: ALB/NLB was already removed by another controller (e.g. aws-load-balancer-controller) and kOps races it; missing elasticloadbalancing:DeleteLoadBalancer IAM permission on v2 ARNs; throttling when deleting many clusters.

Related errors


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