Skip to content

Commit

Permalink
Merge pull request #456 from aledbf/avoid-duplicated-us
Browse files Browse the repository at this point in the history
Avoid upstreams with multiple servers with the same port
  • Loading branch information
aledbf authored Mar 16, 2017
2 parents c25936d + d82544f commit a5f8fe2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/pkg/ingress/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,11 @@ func (ic *GenericController) getEndpoints(

upsServers := []ingress.Endpoint{}

// avoid duplicated upstream servers when the service
// contains multiple port definitions sharing the same
// targetport.
adus := make(map[string]bool, 0)

for _, ss := range ep.Subsets {
for _, epPort := range ss.Ports {

Expand Down Expand Up @@ -1031,13 +1036,18 @@ func (ic *GenericController) getEndpoints(
}

for _, epAddress := range ss.Addresses {
ep := fmt.Sprintf("%v:%v", epAddress.IP, targetPort)
if _, exists := adus[ep]; exists {
continue
}
ups := ingress.Endpoint{
Address: epAddress.IP,
Port: fmt.Sprintf("%v", targetPort),
MaxFails: hz.MaxFails,
FailTimeout: hz.FailTimeout,
}
upsServers = append(upsServers, ups)
adus[ep] = true
}
}
}
Expand Down

0 comments on commit a5f8fe2

Please sign in to comment.