Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namespace/node pool: forward RPCs cross-region if ACLs aren't enabled #20220

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading