{"record":{"id":"3097ae3aa1ea6c78","repo":"kubernetes/kops","slug":"error-deleting-load-balancer-listener-with-arn-q","errorCode":null,"errorMessage":"error deleting load balancer listener with arn=%q: %w","messagePattern":"error deleting load balancer listener with arn=%q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/networkloadbalancerlistener.go","lineNumber":167,"sourceCode":"\n\tif e.NetworkLoadBalancer == nil {\n\t\treturn fi.RequiredField(\"NetworkLoadBalancer\")\n\t}\n\tloadBalancerArn := e.NetworkLoadBalancer.loadBalancerArn\n\tif loadBalancerArn == \"\" {\n\t\treturn fmt.Errorf(\"load balancer not yet created (arn not set)\")\n\t}\n\n\tif a != nil {\n\t\t// TODO: Can we do better here?\n\t\tklog.Warningf(\"deleting ELB listener %q for required changes (%+v)\", a.listenerArn, changes)\n\n\t\t// delete the listener before recreating it\n\t\t_, err := t.Cloud.ELBV2().DeleteListener(ctx, &elbv2.DeleteListenerInput{\n\t\t\tListenerArn: &a.listenerArn,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error deleting load balancer listener with arn=%q: %w\", e.listenerArn, err)\n\t\t}\n\t\ta = nil\n\t}\n\n\tif a == nil {\n\t\tif e.TargetGroup == nil {\n\t\t\treturn fi.RequiredField(\"TargetGroup\")\n\t\t}\n\t\ttargetGroupARN := fi.ValueOf(e.TargetGroup.ARN)\n\t\tif targetGroupARN == \"\" {\n\t\t\treturn fmt.Errorf(\"target group not yet created (arn not set)\")\n\t\t}\n\t\trequest := &elbv2.CreateListenerInput{\n\t\t\tDefaultActions: []elbv2types.Action{\n\t\t\t\t{\n\t\t\t\t\tTargetGroupArn: aws.String(targetGroupARN),\n\t\t\t\t\tType:           elbv2types.ActionTypeEnumForward,\n\t\t\t\t},","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/networkloadbalancerlistener.go#L149-L185","documentation":"When required changes exist on an existing listener, RenderAWS deletes the old listener before recreating it; if ELBV2 DeleteListener fails, this error is returned wrapping the AWS error. The message includes the (empty for new tasks) e.listenerArn rather than a.listenerArn, so the wrapped AWS error is the useful part.","triggerScenarios":"DeleteListener rejected: listener ARN not found (already deleted), IAM permission missing (elasticloadbalancing:DeleteListener), listener in a state that forbids deletion, throttling or network errors.","commonSituations":"Concurrent applies where another run already deleted the listener; IAM policy changes removing delete permissions; force-recreation of listeners after cert/protocol changes.","solutions":["Inspect the wrapped AWS error: ListenerNotFound means it's already gone and recreation can proceed","Verify IAM permissions include elasticloadbalancing:DeleteListener","Retry the apply after transient failures","Avoid concurrent kops applies against the same cluster"],"exampleFix":"// before: fatal on already-deleted\nreturn fmt.Errorf(\"error deleting load balancer listener with arn=%q: %w\", e.listenerArn, err)\n// after: tolerate ListenerNotFound\nvar nf *elbv2types.ListenerNotFoundException\nif errors.As(err, &nf) { a = nil } else { return fmt.Errorf(...) }","handlingStrategy":"try-catch","validationCode":"// confirm listener still exists before delete-recreate\n_, err := t.Cloud.ELBV2().DescribeListeners(&elbv2.DescribeListenersInput{ListenerArns: []string{a.listenerArn}})\nif isNotFound(err) { a = nil } // skip delete","typeGuard":null,"tryCatchPattern":"_, err := t.Cloud.ELBV2().DeleteListener(ctx, &elbv2.DeleteListenerInput{ListenerArn: &a.listenerArn})\nif err != nil {\n  var nf *elbv2types.ListenerNotFoundException\n  if !errors.As(err, &nf) {\n    return fmt.Errorf(\"error deleting load balancer listener with arn=%q: %w\", e.listenerArn, err)\n  }\n}","preventionTips":["Never run concurrent kops applies against one cluster","Keep elasticloadbalancing:DeleteListener IAM permission","Treat ListenerNotFound as already-deleted during recreation","Retry throttled/transient errors with backoff"],"tags":["aws","elbv2","listener","deletion"],"backgroundTag":"listener-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"}