mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 22:49:40 -08:00
Merge pull request #1148 from prometheus/fix-serverset-multiple-paths
Fix watching multiple Zookeeper paths in serverset SD.
This commit is contained in:
commit
dec9fc9c32
|
@ -63,13 +63,13 @@ func (zl zookeeperLogger) Printf(s string, i ...interface{}) {
|
||||||
// ServersetDiscovery retrieves target information from a Serverset server
|
// ServersetDiscovery retrieves target information from a Serverset server
|
||||||
// and updates them via watches.
|
// and updates them via watches.
|
||||||
type ServersetDiscovery struct {
|
type ServersetDiscovery struct {
|
||||||
conf *config.ServersetSDConfig
|
conf *config.ServersetSDConfig
|
||||||
conn *zk.Conn
|
conn *zk.Conn
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
sources map[string]*config.TargetGroup
|
sources map[string]*config.TargetGroup
|
||||||
sdUpdates *chan<- *config.TargetGroup
|
sdUpdates *chan<- *config.TargetGroup
|
||||||
updates chan zookeeperTreeCacheEvent
|
updates chan zookeeperTreeCacheEvent
|
||||||
treeCache *zookeeperTreeCache
|
treeCaches []*zookeeperTreeCache
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServersetDiscovery returns a new ServersetDiscovery for the given config.
|
// NewServersetDiscovery returns a new ServersetDiscovery for the given config.
|
||||||
|
@ -87,7 +87,9 @@ func NewServersetDiscovery(conf *config.ServersetSDConfig) *ServersetDiscovery {
|
||||||
sources: map[string]*config.TargetGroup{},
|
sources: map[string]*config.TargetGroup{},
|
||||||
}
|
}
|
||||||
go sd.processUpdates()
|
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
|
return sd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +145,9 @@ func (sd *ServersetDiscovery) Run(ch chan<- *config.TargetGroup, done <-chan str
|
||||||
sd.mu.Unlock()
|
sd.mu.Unlock()
|
||||||
|
|
||||||
<-done
|
<-done
|
||||||
sd.treeCache.Stop()
|
for _, tc := range sd.treeCaches {
|
||||||
|
tc.Stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseServersetMember(data []byte, path string) (*model.LabelSet, error) {
|
func parseServersetMember(data []byte, path string) (*model.LabelSet, error) {
|
||||||
|
|
Loading…
Reference in a new issue