Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-03-02 11:44:34 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-03-03 10:49:13 +0300
commit941f89efc78b8c54301441fd1873e25175bd1831 (patch)
tree16f8920326e30a7d2e206584bc17cda69d7d7d2b /internal/praefect/router_node_manager.go
parent55bed7acf3bb27ab627272d903d99573c5f009e7 (diff)
praefect: Add `forcePrimary` parameter to `RouteRepositoryAccessor`
Implementations of the Router interface are all forced to check themselves whether they must force-route accessors to the primary node because the RPC's metadata tells them to. While annoying, this hasn't been much of a problem until now given there's only two implementations. But we need to extend the conditions to also take into account what kind of RPC we are currently routing. Currently, the Routers are designed RPC-agnostic though except for an RPC's type, and this should stay this way. Instead, it's the coordinator which should inspect the RPC and tell the router to force-route to primaries. As a preparation for this change, this commit adds a new `forcePrimary` flag to the `Router` interface. If set, it tells the router that it must always route to the primary node. No change in behaviour is expected from this change as we always pass `false` for now.
Diffstat (limited to 'internal/praefect/router_node_manager.go')
-rw-r--r--internal/praefect/router_node_manager.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/praefect/router_node_manager.go b/internal/praefect/router_node_manager.go
index ca45fed88..1a4f1469e 100644
--- a/internal/praefect/router_node_manager.go
+++ b/internal/praefect/router_node_manager.go
@@ -33,8 +33,8 @@ func NewNodeManagerRouter(mgr nodes.Manager, rs datastore.RepositoryStore) Route
return &nodeManagerRouter{mgr: mgr, rs: rs}
}
-func (r *nodeManagerRouter) RouteRepositoryAccessor(ctx context.Context, virtualStorage, relativePath string) (RouterNode, error) {
- if shouldRouteRepositoryAccessorToPrimary(ctx) {
+func (r *nodeManagerRouter) RouteRepositoryAccessor(ctx context.Context, virtualStorage, relativePath string, forcePrimary bool) (RouterNode, error) {
+ if forcePrimary || shouldRouteRepositoryAccessorToPrimary(ctx) {
shard, err := r.mgr.GetShard(ctx, virtualStorage)
if err != nil {
return RouterNode{}, fmt.Errorf("get shard: %w", err)