Merge pull request #842 from prometheus/fabxc/consulcfg
retrieval/discovery: refresh services in Consul to recover from missing events
This commit is contained in:
commit
2677d7b99a
|
@ -180,8 +180,8 @@ func (cd *ConsulDiscovery) watchServices(update chan<- *consulService) {
|
||||||
for {
|
for {
|
||||||
catalog := cd.client.Catalog()
|
catalog := cd.client.Catalog()
|
||||||
srvs, meta, err := catalog.Services(&consul.QueryOptions{
|
srvs, meta, err := catalog.Services(&consul.QueryOptions{
|
||||||
RequireConsistent: false,
|
|
||||||
WaitIndex: lastIndex,
|
WaitIndex: lastIndex,
|
||||||
|
WaitTime: consulWatchTimeout,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error refreshing service list: %s", err)
|
log.Errorf("Error refreshing service list: %s", err)
|
||||||
|
@ -197,6 +197,7 @@ func (cd *ConsulDiscovery) watchServices(update chan<- *consulService) {
|
||||||
cd.mu.Lock()
|
cd.mu.Lock()
|
||||||
select {
|
select {
|
||||||
case <-cd.srvsDone:
|
case <-cd.srvsDone:
|
||||||
|
cd.mu.Unlock()
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
// Continue.
|
// Continue.
|
||||||
|
@ -272,9 +273,11 @@ func (cd *ConsulDiscovery) watchService(srv *consulService, ch chan<- *config.Ta
|
||||||
ConsulTagsLabel: clientmodel.LabelValue(tags),
|
ConsulTagsLabel: clientmodel.LabelValue(tags),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
cd.mu.Lock()
|
cd.mu.Lock()
|
||||||
select {
|
select {
|
||||||
case <-srv.done:
|
case <-srv.done:
|
||||||
|
cd.mu.Unlock()
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
// Continue.
|
// Continue.
|
||||||
|
|
Loading…
Reference in New Issue