Skip to content

Commit

Permalink
Fix refresh in consul_catalog
Browse files Browse the repository at this point in the history
- Copy value of "current" map in "fallback" map
- QueryOption for Service Detail (no DefaultWatchWaitTime)
  • Loading branch information
juliens authored and traefiker committed Sep 20, 2017
1 parent 7d5ecc4 commit f1e36a9
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions provider/consul/consul_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (p *CatalogProvider) watchCatalogServices(stopCh <-chan struct{}, watchCh c
if data != nil {

for key, value := range data {
nodes, _, err := catalog.Service(key, "", options)
nodes, _, err := catalog.Service(key, "", &api.QueryOptions{})
if err != nil {
log.Errorf("Failed to get detail of service %s: %s", key, err)
return
Expand All @@ -243,16 +243,13 @@ func (p *CatalogProvider) watchCatalogServices(stopCh <-chan struct{}, watchCh c

addedServiceNodeKeys, removedServiceNodeKeys := getChangedServiceNodeKeys(current, flashback)

if len(addedServiceKeys) > 0 || len(addedServiceNodeKeys) > 0 {
log.WithField("DiscoveredServices", addedServiceKeys).Debug("Catalog Services change detected.")
if len(removedServiceKeys) > 0 || len(removedServiceNodeKeys) > 0 || len(addedServiceKeys) > 0 || len(addedServiceNodeKeys) > 0 {
log.WithField("MissingServices", removedServiceKeys).WithField("DiscoveredServices", addedServiceKeys).Debug("Catalog Services change detected.")
watchCh <- data
flashback = current
}

if len(removedServiceKeys) > 0 || len(removedServiceNodeKeys) > 0 {
log.WithField("MissingServices", removedServiceKeys).Debug("Catalog Services change detected.")
watchCh <- data
flashback = current
flashback = make(map[string]Service, len(current))
for key, value := range current {
flashback[key] = value
}
}
}
}
Expand Down

0 comments on commit f1e36a9

Please sign in to comment.