Skip to content

Commit 1ea514f

Browse files
authored
Skip listener attributes reconcile for Isolated regions (#3884)
1 parent 808fcbc commit 1ea514f

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

pkg/deploy/elbv2/listener_manager.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package elbv2
33
import (
44
"context"
55
"reflect"
6+
"strings"
67
"time"
78

89
awssdk "github.com/aws/aws-sdk-go-v2/aws"
@@ -101,7 +102,8 @@ func (m *defaultListenerManager) Create(ctx context.Context, resLS *elbv2model.L
101102
}); err != nil {
102103
return elbv2model.ListenerStatus{}, errors.Wrap(err, "failed to update extra certificates on listener")
103104
}
104-
if areListenerAttributesSupported(resLS.Spec.Protocol) {
105+
listenerARN := awssdk.ToString(sdkLS.Listener.ListenerArn)
106+
if !isIsolatedRegion(getRegionFromARN(listenerARN)) && areListenerAttributesSupported(resLS.Spec.Protocol) {
105107
if err := m.attributesReconciler.Reconcile(ctx, resLS, sdkLS); err != nil {
106108
return elbv2model.ListenerStatus{}, err
107109
}
@@ -121,7 +123,8 @@ func (m *defaultListenerManager) Update(ctx context.Context, resLS *elbv2model.L
121123
if err := m.updateSDKListenerWithExtraCertificates(ctx, resLS, sdkLS, false); err != nil {
122124
return elbv2model.ListenerStatus{}, err
123125
}
124-
if areListenerAttributesSupported(resLS.Spec.Protocol) {
126+
listenerARN := awssdk.ToString(sdkLS.Listener.ListenerArn)
127+
if !isIsolatedRegion(getRegionFromARN(listenerARN)) && areListenerAttributesSupported(resLS.Spec.Protocol) {
125128
if err := m.attributesReconciler.Reconcile(ctx, resLS, sdkLS); err != nil {
126129
return elbv2model.ListenerStatus{}, err
127130
}
@@ -379,3 +382,17 @@ func areListenerAttributesSupported(protocol elbv2model.Protocol) bool {
379382
supported, exists := PROTOCOLS_SUPPORTING_LISTENER_ATTRIBUTES[protocol]
380383
return exists && supported
381384
}
385+
386+
func getRegionFromARN(arn string) string {
387+
if strings.HasPrefix(arn, "arn:") {
388+
arnElements := strings.Split(arn, ":")
389+
if len(arnElements) > 3 {
390+
return arnElements[3]
391+
}
392+
}
393+
return ""
394+
}
395+
396+
func isIsolatedRegion(region string) bool {
397+
return strings.Contains(strings.ToLower(region), "-iso-")
398+
}

test/e2e/service/nlb_instance_target_test.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,23 @@ var _ = Describe("test k8s service reconciled by the aws load balancer controlle
160160
})
161161
Expect(err).NotTo(HaveOccurred())
162162
})
163-
By("modifying listener attributes", func() {
164-
err := stack.UpdateServiceAnnotations(ctx, tf, map[string]string{
165-
"service.beta.kubernetes.io/aws-load-balancer-listener-attributes.TCP-80": "tcp.idle_timeout.seconds=400",
166-
})
167-
Expect(err).NotTo(HaveOccurred())
163+
// remove this once listener attributes are available in isolated region
164+
if !strings.Contains(tf.Options.AWSRegion, "-iso-") {
165+
By("modifying listener attributes", func() {
166+
err := stack.UpdateServiceAnnotations(ctx, tf, map[string]string{
167+
"service.beta.kubernetes.io/aws-load-balancer-listener-attributes.TCP-80": "tcp.idle_timeout.seconds=400",
168+
})
169+
Expect(err).NotTo(HaveOccurred())
168170

169-
lsARN := getLoadBalancerListenerARN(ctx, tf, lbARN, "80")
171+
lsARN := getLoadBalancerListenerARN(ctx, tf, lbARN, "80")
170172

171-
Eventually(func() bool {
172-
return verifyListenerAttributes(ctx, tf, lsARN, map[string]string{
173-
"tcp.idle_timeout.seconds": "400",
174-
}) == nil
175-
}, utils.PollTimeoutShort, utils.PollIntervalMedium).Should(BeTrue())
176-
})
173+
Eventually(func() bool {
174+
return verifyListenerAttributes(ctx, tf, lsARN, map[string]string{
175+
"tcp.idle_timeout.seconds": "400",
176+
}) == nil
177+
}, utils.PollTimeoutShort, utils.PollIntervalMedium).Should(BeTrue())
178+
})
179+
}
177180
})
178181
It("should provision internal load-balancer resources", func() {
179182
By("deploying stack", func() {

0 commit comments

Comments
 (0)