Skip to content

Commit

Permalink
Backport of namespace/node pool: forward RPCs cross-region if ACLs ar…
Browse files Browse the repository at this point in the history
…en't enabled into release/1.7.x (#20230)

Co-authored-by: Tim Gross <tgross@hashicorp.com>
  • Loading branch information
hc-github-team-nomad-core and tgross authored Mar 26, 2024
1 parent 732c7d0 commit 145dd13
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/20220.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
namespace/node pool: Fixed a bug where the `-region` flag would not be respected for namespace and node pool updates if ACLs were disabled
```
12 changes: 10 additions & 2 deletions nomad/namespace_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ func (n *Namespace) UpsertNamespaces(args *structs.NamespaceUpsertRequest,
reply *structs.GenericResponse) error {

authErr := n.srv.Authenticate(n.ctx, args)
args.Region = n.srv.config.AuthoritativeRegion
if n.srv.config.ACLEnabled || args.Region == "" {
// only forward to the authoritative region if ACLs are enabled,
// otherwise we silently write to the local region
args.Region = n.srv.config.AuthoritativeRegion
}
if done, err := n.srv.forward("Namespace.UpsertNamespaces", args, args, reply); done {
return err
}
Expand Down Expand Up @@ -77,7 +81,11 @@ func (n *Namespace) UpsertNamespaces(args *structs.NamespaceUpsertRequest,
func (n *Namespace) DeleteNamespaces(args *structs.NamespaceDeleteRequest, reply *structs.GenericResponse) error {

authErr := n.srv.Authenticate(n.ctx, args)
args.Region = n.srv.config.AuthoritativeRegion
if n.srv.config.ACLEnabled || args.Region == "" {
// only forward to the authoritative region if ACLs are enabled,
// otherwise we silently write to the local region
args.Region = n.srv.config.AuthoritativeRegion
}
if done, err := n.srv.forward("Namespace.DeleteNamespaces", args, args, reply); done {
return err
}
Expand Down
12 changes: 10 additions & 2 deletions nomad/node_pool_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ func (n *NodePool) GetNodePool(args *structs.NodePoolSpecificRequest, reply *str
// cannot be updated.
func (n *NodePool) UpsertNodePools(args *structs.NodePoolUpsertRequest, reply *structs.GenericResponse) error {
authErr := n.srv.Authenticate(n.ctx, args)
args.Region = n.srv.config.AuthoritativeRegion
if n.srv.config.ACLEnabled || args.Region == "" {
// only forward to the authoritative region if ACLs are enabled,
// otherwise we silently write to the local region
args.Region = n.srv.config.AuthoritativeRegion
}
if done, err := n.srv.forward("NodePool.UpsertNodePools", args, args, reply); done {
return err
}
Expand Down Expand Up @@ -231,7 +235,11 @@ func (n *NodePool) UpsertNodePools(args *structs.NodePoolUpsertRequest, reply *s
// deleted.
func (n *NodePool) DeleteNodePools(args *structs.NodePoolDeleteRequest, reply *structs.GenericResponse) error {
authErr := n.srv.Authenticate(n.ctx, args)
args.Region = n.srv.config.AuthoritativeRegion
if n.srv.config.ACLEnabled || args.Region == "" {
// only forward to the authoritative region if ACLs are enabled,
// otherwise we silently write to the local region
args.Region = n.srv.config.AuthoritativeRegion
}
if done, err := n.srv.forward("NodePool.DeleteNodePools", args, args, reply); done {
return err
}
Expand Down

0 comments on commit 145dd13

Please sign in to comment.