{"record":{"id":"2f6a92284fdc36c3","repo":"kubernetes/kops","slug":"error-deleting-elb-loadbalancer-q-w","errorCode":null,"errorMessage":"error deleting ELB LoadBalancer %q: %w","messagePattern":"error deleting ELB LoadBalancer %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/network_load_balancer.go","lineNumber":733,"sourceCode":"\tobj *awsup.LoadBalancerInfo\n}\n\nvar _ fi.CloudupDeletion = (*deleteNLB)(nil)\n\nfunc (d *deleteNLB) Delete(t fi.CloudupTarget) error {\n\tctx := context.TODO()\n\n\tawsTarget, ok := t.(*awsup.AWSAPITarget)\n\tif !ok {\n\t\treturn fmt.Errorf(\"unexpected target type for deletion: %T\", t)\n\t}\n\n\tarn := d.obj.ARN()\n\tklog.V(2).Infof(\"deleting load balancer %q\", arn)\n\tif _, err := awsTarget.Cloud.ELBV2().DeleteLoadBalancer(ctx, &elbv2.DeleteLoadBalancerInput{\n\t\tLoadBalancerArn: &arn,\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"error deleting ELB LoadBalancer %q: %w\", arn, err)\n\t}\n\n\treturn nil\n}\n\n// String returns a string representation of the task\nfunc (d *deleteNLB) String() string {\n\treturn d.TaskName() + \"-\" + d.Item()\n}\n\n// TaskName returns the task name\nfunc (d *deleteNLB) TaskName() string {\n\treturn \"network-load-balancer\"\n}\n\n// Item returns the launch template name\nfunc (d *deleteNLB) Item() string {\n\treturn d.obj.ARN()","sourceCodeStart":715,"sourceCodeEnd":751,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/network_load_balancer.go#L715-L751","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the wrapped AWS error: LoadBalancerNotFound usually means it's already gone (safe to proceed)","Verify IAM permissions include elasticloadbalancing:DeleteLoadBalancer","Retry after transient failures; if the ARN is stale, refresh kops state","Manually confirm the NLB's status in the AWS console if deletion is stuck"],"exampleFix":"// before: treating not-found as fatal\nreturn fmt.Errorf(\"error deleting ELB LoadBalancer %q: %w\", arn, err)\n// after: tolerate already-deleted\nvar nf *elbv2types.LoadBalancerNotFoundException\nif errors.As(err, &nf) { return nil }\nreturn fmt.Errorf(\"error deleting ELB LoadBalancer %q: %w\", arn, err)","handlingStrategy":"retry","validationCode":"// pre-check existence to avoid fatal not-found\n_, err := awsTarget.Cloud.ELBV2().DescribeLoadBalancers(&elbv2.DescribeLoadBalancersInput{LoadBalancerArns: []string{arn}})\nif isNotFound(err) { return nil } // already deleted","typeGuard":null,"tryCatchPattern":"if _, err := awsTarget.Cloud.ELBV2().DeleteLoadBalancer(ctx, input); err != nil {\n  var nf *elbv2types.LoadBalancerNotFoundException\n  if errors.As(err, &nf) { return nil }\n  if isThrottling(err) { /* retry with backoff */ }\n  return fmt.Errorf(\"error deleting ELB LoadBalancer %q: %w\", arn, err)\n}","preventionTips":["Grant IAM elasticloadbalancing:DeleteLoadBalancer","Treat not-found as success during teardown","Retry transient AWS errors with exponential backoff","Avoid manual NLB deletion outside kOps to prevent ARN drift"],"tags":["aws","elbv2","load-balancer","deletion"],"backgroundTag":"load-balancer-delete-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"}