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>2022-03-04 10:25:56 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-03-04 10:30:49 +0300
commit87ca0960cfcb446dee9a157fb459b460e4a10593 (patch)
treeac87aca6e97eae6cf3cb9baa47113ef6902bbd0a
parent83081534f551a4a37ac3f841b35397d751026a2f (diff)
praefect: Revert relative path rewriting in RepositoryReplicaspks-revert-repository-replicas-rewriting
With 8d3767c71 (Rewrite relative path in RepositoryReplicas, 2022-03-02) we have introduced rewriting of the repository's relative path for the RepositoryReplicas RPC. This has introduced new usage of the repository store into the code path, which is required such that we can obtain the replica path from the database. Unfortunately, this is causing failures downstream in Rails, which is still not using a database and thus uses a stubbed-out repository store. Fixing this isn't quite trivial because we can't create a simple stub implementation of `GetReplicaPath()`. We'd have two choices: either return successfully with a bogus replica path, or return an error like `ErrRepositoryNotFound`, and neither of those options fixes the failure observed in Rails. Revert the commit for now. We're actively working to migrate Rails to use a database for its tests, so the limitations we have will go away. Furthermore, the actual path rewriting is blocked by the very same migration, so the revert shouldn't block any ongoing work either.
-rw-r--r--internal/praefect/service/info/repositories.go37
1 files changed, 19 insertions, 18 deletions
diff --git a/internal/praefect/service/info/repositories.go b/internal/praefect/service/info/repositories.go
index ec6bb1a4b..ba6f1f90a 100644
--- a/internal/praefect/service/info/repositories.go
+++ b/internal/praefect/service/info/repositories.go
@@ -7,6 +7,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"golang.org/x/sync/errgroup"
+ "google.golang.org/grpc"
)
// RepositoryReplicas returns a list of repositories that includes the checksum of the primary as well as the replicas
@@ -29,11 +30,6 @@ func (s *Server) RepositoryReplicas(ctx context.Context, in *gitalypb.Repository
return nil, fmt.Errorf("get host assignments: %w", err)
}
- replicaPath, err := s.rs.GetReplicaPath(ctx, repositoryID)
- if err != nil {
- return nil, fmt.Errorf("get replica path: %w", err)
- }
-
secondaries := make([]string, 0, len(assignments)-1)
primaryIsAssigned := false
for _, assignment := range assignments {
@@ -51,7 +47,7 @@ func (s *Server) RepositoryReplicas(ctx context.Context, in *gitalypb.Repository
var resp gitalypb.RepositoryReplicasResponse
- if resp.Primary, err = s.getRepositoryDetails(ctx, virtualStorage, primary, relativePath, replicaPath); err != nil {
+ if resp.Primary, err = s.getRepositoryDetails(ctx, virtualStorage, primary, relativePath); err != nil {
return nil, helper.ErrInternal(err)
}
@@ -64,7 +60,7 @@ func (s *Server) RepositoryReplicas(ctx context.Context, in *gitalypb.Repository
storage := storage // rescoping
g.Go(func() error {
var err error
- resp.Replicas[i], err = s.getRepositoryDetails(ctx, virtualStorage, storage, relativePath, replicaPath)
+ resp.Replicas[i], err = s.getRepositoryDetails(ctx, virtualStorage, storage, relativePath)
return err
})
}
@@ -76,28 +72,33 @@ func (s *Server) RepositoryReplicas(ctx context.Context, in *gitalypb.Repository
return &resp, nil
}
-func (s *Server) getRepositoryDetails(ctx context.Context, virtualStorage, storage, relativePath, replicaPath string) (*gitalypb.RepositoryReplicasResponse_RepositoryDetails, error) {
+func (s *Server) getRepositoryDetails(ctx context.Context, virtualStorage, storage, relativePath string) (*gitalypb.RepositoryReplicasResponse_RepositoryDetails, error) {
conn, ok := s.conns[virtualStorage][storage]
if !ok {
return nil, fmt.Errorf("no connection to %q/%q", virtualStorage, storage)
}
- resp, err := gitalypb.NewRepositoryServiceClient(conn).CalculateChecksum(ctx,
+ return getChecksum(
+ ctx,
+ &gitalypb.Repository{
+ StorageName: storage,
+ RelativePath: relativePath,
+ }, conn)
+}
+
+func getChecksum(ctx context.Context, repo *gitalypb.Repository, cc *grpc.ClientConn) (*gitalypb.RepositoryReplicasResponse_RepositoryDetails, error) {
+ client := gitalypb.NewRepositoryServiceClient(cc)
+
+ resp, err := client.CalculateChecksum(ctx,
&gitalypb.CalculateChecksumRequest{
- Repository: &gitalypb.Repository{
- StorageName: storage,
- RelativePath: replicaPath,
- },
+ Repository: repo,
})
if err != nil {
return nil, err
}
return &gitalypb.RepositoryReplicasResponse_RepositoryDetails{
- Repository: &gitalypb.Repository{
- StorageName: storage,
- RelativePath: relativePath,
- },
- Checksum: resp.GetChecksum(),
+ Repository: repo,
+ Checksum: resp.GetChecksum(),
}, nil
}