nomad: RPC layer should check for missing region

This commit is contained in:
Armon Dadgar 2015-07-06 14:18:12 -06:00
parent f16fc93d85
commit 1f8d11eb49
2 changed files with 5 additions and 4 deletions

View file

@ -21,9 +21,6 @@ func (c *Client) Register(args *structs.RegisterRequest, reply *structs.GenericR
defer metrics.MeasureSince([]string{"nomad", "client", "register"}, time.Now()) defer metrics.MeasureSince([]string{"nomad", "client", "register"}, time.Now())
// Validate the arguments // Validate the arguments
if args.Region == "" {
return fmt.Errorf("missing region for client registration")
}
if args.Node == nil { if args.Node == nil {
return fmt.Errorf("missing node for client registration") return fmt.Errorf("missing node for client registration")
} }

View file

@ -168,8 +168,12 @@ func (s *Server) handleNomadConn(conn net.Conn) {
// forward is used to forward to a remote region or to forward to the local leader // forward is used to forward to a remote region or to forward to the local leader
// Returns a bool of if forwarding was performed, as well as any error // Returns a bool of if forwarding was performed, as well as any error
func (s *Server) forward(method string, info structs.RPCInfo, args interface{}, reply interface{}) (bool, error) { func (s *Server) forward(method string, info structs.RPCInfo, args interface{}, reply interface{}) (bool, error) {
// Handle region forwarding
region := info.RequestRegion() region := info.RequestRegion()
if region == "" {
return true, fmt.Errorf("missing target RPC")
}
// Handle region forwarding
if region != s.config.Region { if region != s.config.Region {
err := s.forwardRegion(region, method, args, reply) err := s.forwardRegion(region, method, args, reply)
return true, err return true, err