From 1f8d11eb49c78eb500efa3144dc17265810f3427 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 6 Jul 2015 14:18:12 -0600 Subject: [PATCH] nomad: RPC layer should check for missing region --- nomad/client_endpoint.go | 3 --- nomad/rpc.go | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nomad/client_endpoint.go b/nomad/client_endpoint.go index 8bfc62560..c13cf321b 100644 --- a/nomad/client_endpoint.go +++ b/nomad/client_endpoint.go @@ -21,9 +21,6 @@ func (c *Client) Register(args *structs.RegisterRequest, reply *structs.GenericR defer metrics.MeasureSince([]string{"nomad", "client", "register"}, time.Now()) // Validate the arguments - if args.Region == "" { - return fmt.Errorf("missing region for client registration") - } if args.Node == nil { return fmt.Errorf("missing node for client registration") } diff --git a/nomad/rpc.go b/nomad/rpc.go index d437ebe65..37968e77f 100644 --- a/nomad/rpc.go +++ b/nomad/rpc.go @@ -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 // 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) { - // Handle region forwarding region := info.RequestRegion() + if region == "" { + return true, fmt.Errorf("missing target RPC") + } + + // Handle region forwarding if region != s.config.Region { err := s.forwardRegion(region, method, args, reply) return true, err