From c7cf4fa46c9d8c2de95484d47db15dfb87cdfa47 Mon Sep 17 00:00:00 2001 From: chrislusf Date: Fri, 22 May 2015 08:12:51 -0700 Subject: [PATCH] Fix looking for master nodes. --- go/storage/store.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/go/storage/store.go b/go/storage/store.go index 1d269428a..54a6f9c69 100644 --- a/go/storage/store.go +++ b/go/storage/store.go @@ -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