[REV] optimize node reg to hosts,and optimize collect system info for master

This commit is contained in:
Bay 2017-12-27 12:24:05 +08:00
parent 0bee99c65a
commit 01b9bbef76
3 changed files with 8 additions and 4 deletions

View File

@ -87,7 +87,9 @@ func Run(c *option.Conf) error {
logrus.Errorf(err.Error())
return err
}
if !s.HostNode.Role.HasRule("compute"){
getInfoForMaster(s)
}
ms.Cluster.UpdateNode(s.HostNode)
if err := ms.Start(); err != nil {
logrus.Errorf(err.Error())

View File

@ -395,7 +395,7 @@ func (r *RNodeClient) handleErrAndCode(err error, code int) *util.APIHandleError
return util.CreateAPIHandleError(code, err)
}
if code != 200 {
return util.CreateAPIHandleError(code, fmt.Errorf("error with code %d", code))
return util.CreateAPIHandleError(code, fmt.Errorf("error with code %d,details %s", code,err.Error()))
}
return nil
}

View File

@ -196,6 +196,7 @@ func (n *NodeCluster) loadAndWatchNodes() error {
if !node.Alived {
node.Alived = true
node.UpTime = time.Now()
n.UpdateNode(node)
}
}
}
@ -226,15 +227,16 @@ func (n *NodeCluster) loadAndWatchNodes() error {
if node := n.getNodeFromKey(string(ev.Kv.Key)); node != nil {
node.Alived = true
node.UpTime = time.Now()
RegToHost(node, "add")
//getInfoForMaster(node)
n.UpdateNode(node)
RegToHost(node, "add")
}
case ev.Type == client.EventTypeDelete:
if node := n.getNodeFromKey(string(ev.Kv.Key)); node != nil {
node.Alived = false
node.DownTime = time.Now()
RegToHost(node, "del")
n.UpdateNode(node)
RegToHost(node, "del")
}
}
}