Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions pkg/deploy/elbv2/listener_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package elbv2
import (
"context"
"reflect"
"strings"
"time"

awssdk "github.com/aws/aws-sdk-go-v2/aws"
Expand Down Expand Up @@ -101,7 +102,8 @@ func (m *defaultListenerManager) Create(ctx context.Context, resLS *elbv2model.L
}); err != nil {
return elbv2model.ListenerStatus{}, errors.Wrap(err, "failed to update extra certificates on listener")
}
if areListenerAttributesSupported(resLS.Spec.Protocol) {
listenerARN := awssdk.ToString(sdkLS.Listener.ListenerArn)
if !isIsolatedRegion(getRegionFromARN(listenerARN)) && areListenerAttributesSupported(resLS.Spec.Protocol) {
if err := m.attributesReconciler.Reconcile(ctx, resLS, sdkLS); err != nil {
return elbv2model.ListenerStatus{}, err
}
Expand All @@ -121,7 +123,8 @@ func (m *defaultListenerManager) Update(ctx context.Context, resLS *elbv2model.L
if err := m.updateSDKListenerWithExtraCertificates(ctx, resLS, sdkLS, false); err != nil {
return elbv2model.ListenerStatus{}, err
}
if areListenerAttributesSupported(resLS.Spec.Protocol) {
listenerARN := awssdk.ToString(sdkLS.Listener.ListenerArn)
if !isIsolatedRegion(getRegionFromARN(listenerARN)) && areListenerAttributesSupported(resLS.Spec.Protocol) {
if err := m.attributesReconciler.Reconcile(ctx, resLS, sdkLS); err != nil {
return elbv2model.ListenerStatus{}, err
}
Expand Down Expand Up @@ -379,3 +382,17 @@ func areListenerAttributesSupported(protocol elbv2model.Protocol) bool {
supported, exists := PROTOCOLS_SUPPORTING_LISTENER_ATTRIBUTES[protocol]
return exists && supported
}

func getRegionFromARN(arn string) string {
if strings.HasPrefix(arn, "arn:") {
arnElements := strings.Split(arn, ":")
if len(arnElements) > 3 {
return arnElements[3]
}
}
return ""
}

func isIsolatedRegion(region string) bool {
return strings.Contains(strings.ToLower(region), "-iso-")
}
27 changes: 15 additions & 12 deletions test/e2e/service/nlb_instance_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,23 @@ var _ = Describe("test k8s service reconciled by the aws load balancer controlle
})
Expect(err).NotTo(HaveOccurred())
})
By("modifying listener attributes", func() {
err := stack.UpdateServiceAnnotations(ctx, tf, map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-listener-attributes.TCP-80": "tcp.idle_timeout.seconds=400",
})
Expect(err).NotTo(HaveOccurred())
// remove this once listener attributes are available in isolated region
if !strings.Contains(tf.Options.AWSRegion, "-iso-") {
By("modifying listener attributes", func() {
err := stack.UpdateServiceAnnotations(ctx, tf, map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-listener-attributes.TCP-80": "tcp.idle_timeout.seconds=400",
})
Expect(err).NotTo(HaveOccurred())

lsARN := getLoadBalancerListenerARN(ctx, tf, lbARN, "80")
lsARN := getLoadBalancerListenerARN(ctx, tf, lbARN, "80")

Eventually(func() bool {
return verifyListenerAttributes(ctx, tf, lsARN, map[string]string{
"tcp.idle_timeout.seconds": "400",
}) == nil
}, utils.PollTimeoutShort, utils.PollIntervalMedium).Should(BeTrue())
})
Eventually(func() bool {
return verifyListenerAttributes(ctx, tf, lsARN, map[string]string{
"tcp.idle_timeout.seconds": "400",
}) == nil
}, utils.PollTimeoutShort, utils.PollIntervalMedium).Should(BeTrue())
})
}
})
It("should provision internal load-balancer resources", func() {
By("deploying stack", func() {
Expand Down
Loading