Skip to content

Commit

Permalink
fix lock/unlock, address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbailey committed Jan 29, 2020
1 parent 3d2cc1c commit 6511b8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nomad/client_agent_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (a *Agent) monitor(conn io.ReadWriteCloser) {
args.SetForwarded()
}

// Handle serverID not equal to ours including region forwarding
// Try to forward request to remote region/server
if args.ServerID != "" {
serverToFwd, err := a.forwardFor(args.ServerID, region)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions nomad/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,21 +531,22 @@ func (r *rpcHandler) forwardRegion(region, method string, args interface{}, repl
func (r *rpcHandler) getServer(region, serverID string) (*serverParts, error) {
// Bail if we can't find any servers
r.peerLock.RLock()
defer r.peerLock.RUnlock()

servers := r.peers[region]
if len(servers) == 0 {
r.peerLock.RUnlock()
r.logger.Warn("no path found to region", "region", region)
return nil, structs.ErrNoRegionPath
}

// Lookup server by id or namedoes not exist in requested regiont
// Lookup server by id or name
for _, server := range servers {
if server.Name == serverID || server.ID == serverID {
return server, nil
}
}

return nil, fmt.Errorf("unknown nomad server %s", serverID)
return nil, fmt.Errorf("unknown Nomad server %s", serverID)
}

// streamingRpc creates a connection to the given server and conducts the
Expand Down

0 comments on commit 6511b8d

Please sign in to comment.