Skip to content

Commit

Permalink
fix behavior when serf advertised address on control plane placed
Browse files Browse the repository at this point in the history
in another network - unreachable from nomad clients(client when discovering controlplane by consul, got serf advirtised address, but must get rpc)
  • Loading branch information
tantra35 committed Jan 21, 2022
1 parent 1471de4 commit ee3e952
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2773,7 +2773,7 @@ DISCOLOOP:
continue
}
var peers []string
if err := c.connPool.RPC(region, addr, c.RPCMajorVersion(), "Status.Peers", rpcargs, &peers); err != nil {
if err := c.connPool.RPC(region, addr, c.RPCMajorVersion(), "Status.RpcPeers", rpcargs, &peers); err != nil {
mErr.Errors = append(mErr.Errors, err)
continue
}
Expand Down
23 changes: 23 additions & 0 deletions nomad/status_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,29 @@ func (s *Status) Peers(args *structs.GenericRequest, reply *[]string) error {
return nil
}

// RpcPeers is used to get all the Rpc servers, when gaent discovered them throw consul
func (s *Status) RpcPeers(args *structs.GenericRequest, reply *[]string) error {
if args.Region == "" {
args.Region = s.srv.config.Region
}
if done, err := s.srv.forward("Status.RpcPeers", args, args, reply); done {
return err
}

future := s.srv.raft.GetConfiguration()
if err := future.Error(); err != nil {
return err
}

s.srv.peerLock.RLock()
defer s.srv.peerLock.RUnlock()

for _, server := range future.Configuration().Servers {
*reply = append(*reply, s.srv.localPeers[server.Address].RPCAddr.String())
}
return nil
}

// Members return the list of servers in a cluster that a particular server is
// aware of
func (s *Status) Members(args *structs.GenericRequest, reply *structs.ServerMembersResponse) error {
Expand Down

0 comments on commit ee3e952

Please sign in to comment.