{"record":{"id":"7bd07caff3c30d0b","repo":"kubernetes/kops","slug":"error-deleting-v2-loadbalancer-q-v","errorCode":null,"errorMessage":"error deleting V2 LoadBalancer %q: %v","messagePattern":"error deleting V2 LoadBalancer %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/aws.go","lineNumber":1485,"sourceCode":"\t}\n\treturn nil\n}\n\nfunc DeleteELBV2(cloud fi.Cloud, r *resources.Resource) error {\n\tctx := context.TODO()\n\tc := cloud.(awsup.AWSCloud)\n\tid := r.ID\n\n\tklog.V(2).Infof(\"Deleting ELBV2 %q\", id)\n\trequest := &elbv2.DeleteLoadBalancerInput{\n\t\tLoadBalancerArn: aws.String(id),\n\t}\n\t_, err := c.ELBV2().DeleteLoadBalancer(ctx, request)\n\tif err != nil {\n\t\tif IsDependencyViolation(err) {\n\t\t\treturn err\n\t\t}\n\t\treturn fmt.Errorf(\"error deleting V2 LoadBalancer %q: %v\", id, err)\n\t}\n\treturn nil\n}\n\nfunc DeleteTargetGroup(cloud fi.Cloud, r *resources.Resource) error {\n\tctx := context.TODO()\n\tc := cloud.(awsup.AWSCloud)\n\tid := r.ID\n\n\tklog.V(2).Infof(\"Deleting TargetGroup %q\", id)\n\trequest := &elbv2.DeleteTargetGroupInput{\n\t\tTargetGroupArn: aws.String(id),\n\t}\n\t_, err := c.ELBV2().DeleteTargetGroup(ctx, request)\n\tif err != nil {\n\t\tif IsDependencyViolation(err) {\n\t\t\treturn err\n\t\t}","sourceCodeStart":1467,"sourceCodeEnd":1503,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/aws.go#L1467-L1503","documentation":"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.","triggerScenarios":"ELBV2 DeleteLoadBalancer fails with errors such as AccessDenied, ThrottlingException, LoadBalancerNotFound (already deleted externally), or AuthFailure/invalid ARN during cluster resource teardown.","commonSituations":"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.","solutions":["Retry the operation — transient throttling or racing deletions usually resolve on a subsequent pass.","Confirm the ALB/NLB ARN still exists; if already deleted, continue and let kOps mark it gone.","Check IAM policy grants elasticloadbalancing:DeleteLoadBalancer for the ARN pattern of the ALB/NLB.","If a dependency violation is reported, first delete listeners/target groups or other attached resources.","Investigate the wrapped %v detail from the AWS SDK for the exact AWS error code."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"out, err := c.ELBV2().DescribeLoadBalancers(ctx, &elbv2.DescribeLoadBalancersInput{\n    LoadBalancerArns: []string{id},\n})\nif err != nil || len(out.LoadBalancers) == 0 { /* already deleted; skip */ }","typeGuard":null,"tryCatchPattern":"if err := DeleteELBV2(cloud, r); err != nil {\n    code := awsup.AWSErrorCode(errors.Unwrap(err))\n    if code == \"ThrottlingException\" { backoff-and-retry }\n    else { record for next reconciliation pass }\n}","preventionTips":["Verify the ALB/NLB ARN exists before delete to avoid racing other controllers.","Include elasticloadbalancing:* delete permissions for v2 ARNs in IAM.","Delete listeners/target groups before the LB when orchestrating manually.","Throttle concurrent AWS API calls in large teardowns.","Treat NotFound as success and continue."],"tags":["aws","alb","nlb","elbv2","deletion"],"backgroundTag":"aws-api-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"}