Merge pull request #1148 from prometheus/fix-serverset-multiple-paths

Fix watching multiple Zookeeper paths in serverset SD.
This commit is contained in:
Julius Volz 2015-10-08 19:27:06 +02:00
commit dec9fc9c32

View File

@ -69,7 +69,7 @@ type ServersetDiscovery struct {
sources map[string]*config.TargetGroup
sdUpdates *chan<- *config.TargetGroup
updates chan zookeeperTreeCacheEvent
treeCache *zookeeperTreeCache
treeCaches []*zookeeperTreeCache
}
// NewServersetDiscovery returns a new ServersetDiscovery for the given config.
@ -87,7 +87,9 @@ func NewServersetDiscovery(conf *config.ServersetSDConfig) *ServersetDiscovery {
sources: map[string]*config.TargetGroup{},
}
go sd.processUpdates()
sd.treeCache = newZookeeperTreeCache(conn, conf.Paths[0], updates)
for _, path := range conf.Paths {
sd.treeCaches = append(sd.treeCaches, newZookeeperTreeCache(conn, path, updates))
}
return sd
}
@ -143,7 +145,9 @@ func (sd *ServersetDiscovery) Run(ch chan<- *config.TargetGroup, done <-chan str
sd.mu.Unlock()
<-done
sd.treeCache.Stop()
for _, tc := range sd.treeCaches {
tc.Stop()
}
}
func parseServersetMember(data []byte, path string) (*model.LabelSet, error) {