Skip to content

Commit

Permalink
Dedup targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Vendetta committed Feb 12, 2020
1 parent b0a3f37 commit 5e25d82
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion source/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,20 @@ func (sc *serviceSource) extractHeadlessEndpoints(svc *v1.Service, hostname stri
}
sort.Strings(headlessDomains)
for _, headlessDomain := range headlessDomains {
targets := targetsByHeadlessDomain[headlessDomain]
allTargets := targetsByHeadlessDomain[headlessDomain]
targets := []string{}

deduppedTargets := map[string]bool{}
for _, target := range allTargets {
if _, ok := deduppedTargets[target]; ok {
log.Debugf("Removing duplicate target %s", target)
continue
}

deduppedTargets[target] = true
targets = append(targets, target)
}

if ttl.IsConfigured() {
endpoints = append(endpoints, endpoint.NewEndpointWithTTL(headlessDomain, endpoint.RecordTypeA, ttl, targets...))
} else {
Expand Down

0 comments on commit 5e25d82

Please sign in to comment.