Browse Source

avoid switching master node if same ip and host name

fix https://github.com/chrislusf/seaweedfs/issues/955
pull/991/head
Chris Lu 6 years ago
parent
commit
017d0957c3
  1. 16
      weed/server/volume_grpc_client_to_master.go

16
weed/server/volume_grpc_client_to_master.go

@ -2,6 +2,7 @@ package weed_server
import ( import (
"fmt" "fmt"
"net"
"time" "time"
"github.com/chrislusf/seaweedfs/weed/security" "github.com/chrislusf/seaweedfs/weed/security"
@ -79,7 +80,7 @@ func (vs *VolumeServer) doHeartbeat(ctx context.Context, masterNode, masterGrpcA
if in.GetVolumeSizeLimit() != 0 { if in.GetVolumeSizeLimit() != 0 {
vs.store.SetVolumeSizeLimit(in.GetVolumeSizeLimit()) vs.store.SetVolumeSizeLimit(in.GetVolumeSizeLimit())
} }
if in.GetLeader() != "" && masterNode != in.GetLeader() {
if in.GetLeader() != "" && masterNode != in.GetLeader() && !isSameIP(in.GetLeader(), masterNode) {
glog.V(0).Infof("Volume Server found a new master newLeader: %v instead of %v", in.GetLeader(), masterNode) glog.V(0).Infof("Volume Server found a new master newLeader: %v instead of %v", in.GetLeader(), masterNode)
newLeader = in.GetLeader() newLeader = in.GetLeader()
doneChan <- nil doneChan <- nil
@ -130,3 +131,16 @@ func (vs *VolumeServer) doHeartbeat(ctx context.Context, masterNode, masterGrpcA
} }
} }
} }
func isSameIP(ip string, host string) bool {
ips, err := net.LookupIP(host)
if err != nil {
return false
}
for _, t := range ips {
if ip == t.String() {
return true
}
}
return false
}
Loading…
Cancel
Save