{"record":{"id":"6e0ad2edd145e3a6","repo":"kubernetes/kops","slug":"error-deleting-loadbalancer-q-v","errorCode":null,"errorMessage":"error deleting LoadBalancer %q: %v","messagePattern":"error deleting LoadBalancer %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/aws/aws.go","lineNumber":1466,"sourceCode":"\treturn nil\n}\n\nfunc DeleteELB(cloud fi.Cloud, r *resources.Resource) error {\n\tctx := context.TODO()\n\tc := cloud.(awsup.AWSCloud)\n\n\tid := r.ID\n\n\tklog.V(2).Infof(\"Deleting ELB %q\", id)\n\trequest := &elb.DeleteLoadBalancerInput{\n\t\tLoadBalancerName: &id,\n\t}\n\t_, err := c.ELB().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 LoadBalancer %q: %v\", id, err)\n\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}","sourceCodeStart":1448,"sourceCodeEnd":1484,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/aws/aws.go#L1448-L1484","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run the delete operation; ELB deletion errors during teardown are often transient (throttling/rate limits) and resource deletion is resumable.","Check IAM permissions for the caller include elasticloadbalancing:DeleteLoadBalancer on the ELB ARNs.","Verify the ELB still exists (aws elb describe-load-balancers) — if already gone, kOps can proceed on the next pass.","If IsDependencyViolation, remove dependent resources (e.g. targets/listeners/Route53 records) first; that path returns the raw error instead.","Reduce concurrency or retry later to avoid AWS throttling."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check the ELB still exists and caller has permission before deleting\nout, err := c.ELB().DescribeLoadBalancers(ctx, &elb.DescribeLoadBalancersInput{\n    LoadBalancerNames: []string{id},\n})\nif err != nil || len(out.LoadBalancerDescriptions) == 0 { /* already gone; skip */ }","typeGuard":null,"tryCatchPattern":"err := DeleteELB(cloud, r)\nif err != nil {\n    if awsup.AWSErrorCode(err) == \"ThrottlingException\" {\n        time.Sleep(backoff); return retry()\n    }\n    return fmt.Errorf(\"elb %s not deleted, will retry on next pass: %w\", id, err)\n}","preventionTips":["Retry teardown passes instead of failing hard; deletions are idempotent-ish and resumable.","Ensure IAM policies cover elasticloadbalancing:DeleteLoadBalancer/DescribeLoadBalancers/DescribeTags.","Avoid parallel kOps deletes against the same cluster's ELBs.","Add exponential backoff for Throttling errors.","Log the wrapped AWS error code for diagnosis."],"tags":["aws","elb","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-12T12:17:11.808Z"}