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:
authorSami Hiltunen <shiltunen@gitlab.com>2021-10-26 10:32:12 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2021-10-26 10:41:14 +0300
commitc4ac72f8a3c851e56ceef4357b0d44d3a8cf2e17 (patch)
tree88321aa19b84e3085ecd1e626975bb18bf46bf67
parent713bcd2cf4aad57750911cfee60db136a46e4b0c (diff)
praefect: Don't query for replica path in NodeManagerRouter
Rails tests are stuck with using NodeManagerRouter and the legacy election strategies due to not using a database. As there's no database, the NodeManagerRouter is used with a stubbed out RepositoryStore. This stub doesn't know anything about the replica paths the repositories have. As the NodeManagerRouter and the election strategies are unsupported and don't need to support the Praefect generated relative paths, let's just use the relative path as the replica path to fix the tests.
-rw-r--r--internal/praefect/router_node_manager.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/praefect/router_node_manager.go b/internal/praefect/router_node_manager.go
index 18f3083b8..10a14c43f 100644
--- a/internal/praefect/router_node_manager.go
+++ b/internal/praefect/router_node_manager.go
@@ -80,7 +80,11 @@ func (r *nodeManagerRouter) RouteRepositoryMutator(ctx context.Context, virtualS
return RepositoryMutatorRoute{}, fmt.Errorf("get shard: %w", err)
}
- replicaPath, consistentStorages, err := r.rs.GetConsistentStorages(ctx, virtualStorage, relativePath)
+ // The replica path is ignored as Rails' tests are the only user of NodeManagerRouter. The tests don't
+ // set up a database, so the RepositoryStore here is always a mock. The mock doesn't know about the replica
+ // paths of repositories and thus returns an empty string. This breaks the tests. Instead, we'll just keep
+ // using the relative path in NodeManagerRouter.
+ _, consistentStorages, err := r.rs.GetConsistentStorages(ctx, virtualStorage, relativePath)
if err != nil && !errors.As(err, new(commonerr.RepositoryNotFoundError)) {
return RepositoryMutatorRoute{}, fmt.Errorf("consistent storages: %w", err)
}
@@ -111,7 +115,7 @@ func (r *nodeManagerRouter) RouteRepositoryMutator(ctx context.Context, virtualS
}
return RepositoryMutatorRoute{
- ReplicaPath: replicaPath,
+ ReplicaPath: relativePath,
Primary: toRouterNode(shard.Primary),
Secondaries: toRouterNodes(participatingSecondaries),
ReplicationTargets: replicationTargets,