mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 22:49:40 -08:00
retrieval: Handle serverset node not existing.
This stops configuration loading hanging if the Znode doesn't exist, and retries until the node does exist.
This commit is contained in:
parent
049a106821
commit
3d268d681e
|
@ -223,6 +223,7 @@ func NewZookeeperTreeCache(conn *zk.Conn, path string, events chan zookeeperTree
|
||||||
tc.head = &zookeeperTreeCacheNode{
|
tc.head = &zookeeperTreeCacheNode{
|
||||||
events: make(chan zk.Event),
|
events: make(chan zk.Event),
|
||||||
children: map[string]*zookeeperTreeCacheNode{},
|
children: map[string]*zookeeperTreeCacheNode{},
|
||||||
|
stopped: true,
|
||||||
}
|
}
|
||||||
err := tc.recursiveNodeUpdate(path, tc.head)
|
err := tc.recursiveNodeUpdate(path, tc.head)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -279,16 +280,20 @@ func (tc *zookeeperTreeCache) loop(failureMode bool) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error during processing of Zookeeper event: %s", err)
|
log.Errorf("Error during processing of Zookeeper event: %s", err)
|
||||||
failure()
|
failure()
|
||||||
|
} else if tc.head.data == nil {
|
||||||
|
log.Errorf("Error during processing of Zookeeper event: path %s no longer exists", tc.prefix)
|
||||||
|
failure()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case <-retryChan:
|
case <-retryChan:
|
||||||
log.Infof("Attempting to resync state with Zookeeper")
|
log.Infof("Attempting to resync state with Zookeeper")
|
||||||
err := tc.recursiveNodeUpdate(tc.prefix, tc.head)
|
err := tc.recursiveNodeUpdate(tc.prefix, tc.head)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
failureMode = false
|
|
||||||
} else {
|
|
||||||
log.Errorf("Error during Zookeeper resync: %s", err)
|
log.Errorf("Error during Zookeeper resync: %s", err)
|
||||||
failure()
|
failure()
|
||||||
|
} else {
|
||||||
|
log.Infof("Zookeeper resync successful")
|
||||||
|
failureMode = false
|
||||||
}
|
}
|
||||||
case <-tc.stop:
|
case <-tc.stop:
|
||||||
close(tc.events)
|
close(tc.events)
|
||||||
|
@ -301,6 +306,9 @@ func (tc *zookeeperTreeCache) recursiveNodeUpdate(path string, node *zookeeperTr
|
||||||
data, _, dataWatcher, err := tc.conn.GetW(path)
|
data, _, dataWatcher, err := tc.conn.GetW(path)
|
||||||
if err == zk.ErrNoNode {
|
if err == zk.ErrNoNode {
|
||||||
tc.recursiveDelete(path, node)
|
tc.recursiveDelete(path, node)
|
||||||
|
if node == tc.head {
|
||||||
|
return fmt.Errorf("path %s does not exist", path)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue