Protect against args being modified
This commit is contained in:
parent
52fd31af80
commit
0da7130a1a
|
@ -78,11 +78,12 @@ type Node struct {
|
|||
|
||||
// Register is used to upsert a client that is available for scheduling
|
||||
func (n *Node) Register(args *structs.NodeRegisterRequest, reply *structs.NodeUpdateResponse) error {
|
||||
isForwarded := args.IsForwarded()
|
||||
if done, err := n.srv.forward("Node.Register", args, args, reply); done {
|
||||
// We have a valid node connection since there is no error from the
|
||||
// forwarded server, so add the mapping to cache the
|
||||
// connection and allow the server to send RPCs to the client.
|
||||
if err == nil && n.ctx != nil && n.ctx.NodeID == "" && !args.IsForwarded() {
|
||||
if err == nil && n.ctx != nil && n.ctx.NodeID == "" && !isForwarded {
|
||||
n.ctx.NodeID = args.Node.ID
|
||||
n.srv.addNodeConn(n.ctx)
|
||||
}
|
||||
|
@ -370,11 +371,12 @@ func (n *Node) deregister(args *structs.NodeBatchDeregisterRequest,
|
|||
|
||||
// UpdateStatus is used to update the status of a client node
|
||||
func (n *Node) UpdateStatus(args *structs.NodeUpdateStatusRequest, reply *structs.NodeUpdateResponse) error {
|
||||
isForwarded := args.IsForwarded()
|
||||
if done, err := n.srv.forward("Node.UpdateStatus", args, args, reply); done {
|
||||
// We have a valid node connection since there is no error from the
|
||||
// forwarded server, so add the mapping to cache the
|
||||
// connection and allow the server to send RPCs to the client.
|
||||
if err == nil && n.ctx != nil && n.ctx.NodeID == "" && !args.IsForwarded() {
|
||||
if err == nil && n.ctx != nil && n.ctx.NodeID == "" && !isForwarded {
|
||||
n.ctx.NodeID = args.NodeID
|
||||
n.srv.addNodeConn(n.ctx)
|
||||
}
|
||||
|
@ -921,11 +923,12 @@ func (n *Node) GetAllocs(args *structs.NodeSpecificRequest,
|
|||
// per allocation.
|
||||
func (n *Node) GetClientAllocs(args *structs.NodeSpecificRequest,
|
||||
reply *structs.NodeClientAllocsResponse) error {
|
||||
isForwarded := args.IsForwarded()
|
||||
if done, err := n.srv.forward("Node.GetClientAllocs", args, args, reply); done {
|
||||
// We have a valid node connection since there is no error from the
|
||||
// forwarded server, so add the mapping to cache the
|
||||
// connection and allow the server to send RPCs to the client.
|
||||
if err == nil && n.ctx != nil && n.ctx.NodeID == "" && !args.IsForwarded() {
|
||||
if err == nil && n.ctx != nil && n.ctx.NodeID == "" && !isForwarded {
|
||||
n.ctx.NodeID = args.NodeID
|
||||
n.srv.addNodeConn(n.ctx)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue