Skip to content

Commit b1c9d87

Browse files
authored
Merge pull request #648 from M00nF1sh/fix_625
Fix bug as in #625
2 parents 68eb9db + 1612a1a commit b1c9d87

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

internal/alb/lb/loadbalancer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ func (l *LoadBalancer) Reconcile(rOpts *ReconcileOptions) []error {
270270
l.listeners = ltnrs
271271
}
272272

273+
// TODO: currently this works fine since every listener get same actions,
274+
// when this precondition don't hold, we need to consider deletion at cross-listener level.
275+
273276
// Does not consider TG used for listener default action
274277
for _, listener := range l.listeners {
275278
unusedTGs := listener.GetRules().FindUnusedTGs(l.targetgroups, listener.DefaultActionArn())

internal/alb/ls/listener.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func (l *Listener) DefaultActionArn() *string {
336336
if l.ls.current == nil || len(l.ls.current.DefaultActions) < 1 || l.ls.current.DefaultActions[0].Type == nil {
337337
return nil
338338
}
339-
if *l.ls.current.DefaultActions[0].Type == elbv2.ActionTypeEnumRedirect {
339+
if *l.ls.current.DefaultActions[0].Type == elbv2.ActionTypeEnumForward {
340340
return l.ls.current.DefaultActions[0].TargetGroupArn
341341
}
342342
return nil

internal/alb/tg/targetgroups.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,17 @@ func NewDesiredTargetGroups(o *NewDesiredTargetGroupsOptions) (TargetGroups, err
119119
}
120120

121121
var targetGroupsInUse TargetGroups
122+
backendsProcessed := make(map[string]bool)
122123
for _, backend := range backends {
123124
if action.Use(backend.ServicePort.String()) {
124125
// action annotations do not need target groups
125126
continue
126127
}
128+
backendName := backend.ServiceName + ":" + backend.ServicePort.String()
129+
if _, ok := backendsProcessed[backendName]; ok {
130+
continue
131+
}
132+
backendsProcessed[backendName] = true
127133

128134
targetGroup, err := NewDesiredTargetGroupFromBackend(&NewDesiredTargetGroupFromBackendOptions{
129135
Backend: backend,

0 commit comments

Comments
 (0)