Skip to content

Commit

Permalink
Merge pull request #648 from M00nF1sh/fix_625
Browse files Browse the repository at this point in the history
Fix bug as in #625
  • Loading branch information
k8s-ci-robot committed Sep 26, 2018
2 parents 68eb9db + 1612a1a commit b1c9d87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions internal/alb/lb/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ func (l *LoadBalancer) Reconcile(rOpts *ReconcileOptions) []error {
l.listeners = ltnrs
}

// TODO: currently this works fine since every listener get same actions,
// when this precondition don't hold, we need to consider deletion at cross-listener level.

// Does not consider TG used for listener default action
for _, listener := range l.listeners {
unusedTGs := listener.GetRules().FindUnusedTGs(l.targetgroups, listener.DefaultActionArn())
Expand Down
2 changes: 1 addition & 1 deletion internal/alb/ls/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func (l *Listener) DefaultActionArn() *string {
if l.ls.current == nil || len(l.ls.current.DefaultActions) < 1 || l.ls.current.DefaultActions[0].Type == nil {
return nil
}
if *l.ls.current.DefaultActions[0].Type == elbv2.ActionTypeEnumRedirect {
if *l.ls.current.DefaultActions[0].Type == elbv2.ActionTypeEnumForward {
return l.ls.current.DefaultActions[0].TargetGroupArn
}
return nil
Expand Down
6 changes: 6 additions & 0 deletions internal/alb/tg/targetgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,17 @@ func NewDesiredTargetGroups(o *NewDesiredTargetGroupsOptions) (TargetGroups, err
}

var targetGroupsInUse TargetGroups
backendsProcessed := make(map[string]bool)
for _, backend := range backends {
if action.Use(backend.ServicePort.String()) {
// action annotations do not need target groups
continue
}
backendName := backend.ServiceName + ":" + backend.ServicePort.String()
if _, ok := backendsProcessed[backendName]; ok {
continue
}
backendsProcessed[backendName] = true

targetGroup, err := NewDesiredTargetGroupFromBackend(&NewDesiredTargetGroupFromBackendOptions{
Backend: backend,
Expand Down

0 comments on commit b1c9d87

Please sign in to comment.