Fix looking for master nodes.

This commit is contained in:
chrislusf 2015-05-22 08:12:51 -07:00
parent 99aee22e08
commit c7cf4fa46c

View file

@ -43,7 +43,9 @@ func NewMasterNodes(bootstrapNode string) (mn *MasterNodes) {
return
}
func (mn *MasterNodes) reset() {
glog.V(4).Infof("Resetting master nodes: %v", mn)
if len(mn.nodes) > 1 && mn.lastNode > 0 {
glog.V(0).Infof("Reset master %s from: %v", mn.nodes[mn.lastNode], mn.nodes)
mn.lastNode = -mn.lastNode
}
}
@ -58,9 +60,9 @@ func (mn *MasterNodes) findMaster() (string, error) {
if len(masters) == 0 {
continue
}
mn.nodes = masters
mn.nodes = append(masters, m)
mn.lastNode = rand.Intn(len(mn.nodes))
glog.V(2).Info("current master node is :", mn.nodes[mn.lastNode])
glog.V(2).Infof("current master nodes is %v", mn)
break
} else {
glog.V(4).Infof("Failed listing masters on %s: %v", m, e)
@ -321,9 +323,11 @@ func (s *Store) SendHeartbeatToMaster() (masterNode string, secretKey security.S
var ret operation.JoinResult
if err := json.Unmarshal(jsonBlob, &ret); err != nil {
glog.V(0).Infof("Failed to join %s with response: %s", joinUrl, string(jsonBlob))
s.masterNodes.reset()
return masterNode, "", err
}
if ret.Error != "" {
s.masterNodes.reset()
return masterNode, "", errors.New(ret.Error)
}
s.volumeSizeLimit = ret.VolumeSizeLimit