Browse Source
Merge pull request #3249 from kmlebedev/issues_2589
avoid set currentMaster svc.local k8s discovery service domains
pull/3250/head
Chris Lu
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
11 additions and
7 deletions
-
weed/security/tls.go
-
weed/server/master_grpc_server.go
-
weed/wdclient/masterclient.go
|
|
@ -35,7 +35,7 @@ func LoadServerTLS(config *util.ViperProxy, component string) (grpc.ServerOption |
|
|
|
|
|
|
|
serverIdentityProvider, err := pemfile.NewProvider(serverOptions) |
|
|
|
if err != nil { |
|
|
|
glog.Warningf("pemfile.NewProvider(%v) failed: %v", serverOptions, err) |
|
|
|
glog.Warningf("pemfile.NewProvider(%v) %v failed: %v", serverOptions, component, err) |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -263,8 +263,12 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ |
|
|
|
} |
|
|
|
ms.deleteClient(clientName) |
|
|
|
}() |
|
|
|
|
|
|
|
for _, message := range ms.Topo.ToVolumeLocations() { |
|
|
|
for i, message := range ms.Topo.ToVolumeLocations() { |
|
|
|
if i == 0 { |
|
|
|
if leader, err := ms.Topo.Leader(); err == nil { |
|
|
|
message.Leader = string(leader) |
|
|
|
} |
|
|
|
} |
|
|
|
if sendErr := stream.Send(&master_pb.KeepConnectedResponse{VolumeLocation: message}); sendErr != nil { |
|
|
|
return sendErr |
|
|
|
} |
|
|
|
|
|
@ -168,8 +168,8 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL |
|
|
|
} |
|
|
|
|
|
|
|
// check if it is the leader to determine whether to reset the vidMap
|
|
|
|
if resp.VolumeLocation != nil && resp.VolumeLocation.Leader != "" { |
|
|
|
glog.V(0).Infof("redirected to leader %v", resp.VolumeLocation.Leader) |
|
|
|
if resp.VolumeLocation != nil && resp.VolumeLocation.Leader != "" && string(master) != resp.VolumeLocation.Leader { |
|
|
|
glog.V(0).Infof("master %v redirected to leader %v", master, resp.VolumeLocation.Leader) |
|
|
|
nextHintedLeader = pb.ServerAddress(resp.VolumeLocation.Leader) |
|
|
|
stats.MasterClientConnectCounter.WithLabelValues(stats.RedirectedToleader).Inc() |
|
|
|
return nil |
|
|
@ -188,8 +188,8 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL |
|
|
|
|
|
|
|
if resp.VolumeLocation != nil { |
|
|
|
// maybe the leader is changed
|
|
|
|
if resp.VolumeLocation.Leader != "" { |
|
|
|
glog.V(0).Infof("redirected to leader %v", resp.VolumeLocation.Leader) |
|
|
|
if resp.VolumeLocation.Leader != "" && string(mc.currentMaster) != resp.VolumeLocation.Leader { |
|
|
|
glog.V(0).Infof("currentMaster %v redirected to leader %v", mc.currentMaster, resp.VolumeLocation.Leader) |
|
|
|
nextHintedLeader = pb.ServerAddress(resp.VolumeLocation.Leader) |
|
|
|
stats.MasterClientConnectCounter.WithLabelValues(stats.RedirectedToleader).Inc() |
|
|
|
return nil |
|
|
|