Skip to content

Commit

Permalink
Update rule management to avoid sporadic 503 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
shraddhabang committed Feb 26, 2025
1 parent 42385aa commit 7541235
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/deploy/elbv2/listener_rule_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
elbv2model "sigs.k8s.io/aws-load-balancer-controller/pkg/model/elbv2"
"sigs.k8s.io/aws-load-balancer-controller/pkg/runtime"
"slices"
"sort"
"strconv"
"time"
)
Expand Down Expand Up @@ -128,6 +129,12 @@ func (m *defaultListenerRuleManager) SetRulePriorities(ctx context.Context, matc
var lastAvailablePriority int32 = 50000
var sdkLRs []ListenerRuleWithTags

// Sort the unmatched existing SDK rules based on their priority to be pushed down in same order
sort.Slice(unmatchedSDKLRs, func(i, j int) bool {
priorityI, _ := strconv.Atoi(awssdk.ToString(unmatchedSDKLRs[i].ListenerRule.Priority))
priorityJ, _ := strconv.Atoi(awssdk.ToString(unmatchedSDKLRs[j].ListenerRule.Priority))
return priorityI < priorityJ
})
// Push down all the unmatched existing SDK rules on load balancer so that updated rules can take their place
for _, sdkLR := range slices.Backward(unmatchedSDKLRs) {
sdkLR.ListenerRule.Priority = awssdk.String(strconv.Itoa(int(lastAvailablePriority)))
Expand Down

0 comments on commit 7541235

Please sign in to comment.