From 23862c92c4430afec3012f70cecdd8afdd79fa95 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Wed, 24 Jun 2015 17:46:11 +0200 Subject: [PATCH] retrieval/discovery: refresh services in Consul to recover from missing events. --- retrieval/discovery/consul.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/retrieval/discovery/consul.go b/retrieval/discovery/consul.go index 01299af8e..e3c05eb7a 100644 --- a/retrieval/discovery/consul.go +++ b/retrieval/discovery/consul.go @@ -180,8 +180,8 @@ func (cd *ConsulDiscovery) watchServices(update chan<- *consulService) { for { catalog := cd.client.Catalog() srvs, meta, err := catalog.Services(&consul.QueryOptions{ - RequireConsistent: false, - WaitIndex: lastIndex, + WaitIndex: lastIndex, + WaitTime: consulWatchTimeout, }) if err != nil { log.Errorf("Error refreshing service list: %s", err) @@ -197,6 +197,7 @@ func (cd *ConsulDiscovery) watchServices(update chan<- *consulService) { cd.mu.Lock() select { case <-cd.srvsDone: + cd.mu.Unlock() return default: // Continue. @@ -272,9 +273,11 @@ func (cd *ConsulDiscovery) watchService(srv *consulService, ch chan<- *config.Ta ConsulTagsLabel: clientmodel.LabelValue(tags), }) } + cd.mu.Lock() select { case <-srv.done: + cd.mu.Unlock() return default: // Continue.