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-01-29 17:06:46 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-01-29 17:06:46 +0300
commitfaf1cc2e999d73af71285b538914eefff66d0c65 (patch)
tree91b6b36720a3cf706987901fc2b14c604d94e2fd
parent8d24bf509b9c9deba8725fb27fc93251c486c290 (diff)
repository: Inject transaction transaction manager
We'll need the transaction manager in the RepositoryService in order to enable transactional voting for RPCs which modify the repository state. So let's inject the manager to make it available.
-rw-r--r--cmd/gitaly-ssh/auth_test.go4
-rw-r--r--cmd/gitaly/main.go10
-rw-r--r--internal/gitaly/maintenance/optimize_test.go3
-rw-r--r--internal/gitaly/server/auth_test.go5
-rw-r--r--internal/gitaly/server/server.go13
-rw-r--r--internal/gitaly/server/server_factory.go16
-rw-r--r--internal/gitaly/server/server_factory_test.go6
-rw-r--r--internal/gitaly/service/conflicts/resolve_conflicts_test.go3
-rw-r--r--internal/gitaly/service/operations/testhelper_test.go2
-rw-r--r--internal/gitaly/service/register.go14
-rw-r--r--internal/gitaly/service/remote/fetch_internal_remote_test.go3
-rw-r--r--internal/gitaly/service/repository/fetch_test.go4
-rw-r--r--internal/gitaly/service/repository/replicate_test.go3
-rw-r--r--internal/gitaly/service/repository/search_files_test.go5
-rw-r--r--internal/gitaly/service/repository/server.go11
-rw-r--r--internal/gitaly/service/repository/testhelper_test.go2
-rw-r--r--internal/praefect/replicator_test.go6
-rw-r--r--internal/praefect/server_factory_test.go2
-rw-r--r--internal/praefect/service/info/consistencycheck_test.go3
-rw-r--r--internal/testhelper/testserver/gitaly.go4
20 files changed, 80 insertions, 39 deletions
diff --git a/cmd/gitaly-ssh/auth_test.go b/cmd/gitaly-ssh/auth_test.go
index f1fa0fdeb..8ab17bdd1 100644
--- a/cmd/gitaly-ssh/auth_test.go
+++ b/cmd/gitaly-ssh/auth_test.go
@@ -127,11 +127,11 @@ func TestConnectivity(t *testing.T) {
}
}
-func runServer(t *testing.T, newServer func(rubyServer *rubyserver.Server, hookManager hook.Manager, cfg config.Cfg, conns *client.Pool) *grpc.Server, cfg config.Cfg, connectionType string, addr string) (int, func()) {
+func runServer(t *testing.T, newServer func(rubyServer *rubyserver.Server, hookManager hook.Manager, txManager transaction.Manager, cfg config.Cfg, conns *client.Pool) *grpc.Server, cfg config.Cfg, connectionType string, addr string) (int, func()) {
conns := client.NewPool()
txManager := transaction.NewManager(cfg)
hookManager := hook.NewManager(config.NewLocator(cfg), txManager, hook.GitlabAPIStub, cfg)
- srv := newServer(nil, hookManager, cfg, conns)
+ srv := newServer(nil, hookManager, txManager, cfg, conns)
listener, err := net.Listen(connectionType, addr)
require.NoError(t, err)
diff --git a/cmd/gitaly/main.go b/cmd/gitaly/main.go
index 9b616fa12..65d5378ad 100644
--- a/cmd/gitaly/main.go
+++ b/cmd/gitaly/main.go
@@ -128,7 +128,11 @@ func run(cfg config.Cfg, b *bootstrap.Bootstrap) error {
var gitlabAPI hook.GitlabAPI
var err error
+ transactionManager := transaction.NewManager(cfg)
+ prometheus.MustRegister(transactionManager)
+
hookManager := hook.Manager(hook.DisabledManager{})
+
if config.SkipHooks() {
log.Warn("skipping GitLab API client creation since hooks are bypassed via GITALY_TESTING_NO_GIT_HOOKS")
} else {
@@ -137,9 +141,7 @@ func run(cfg config.Cfg, b *bootstrap.Bootstrap) error {
log.Fatalf("could not create GitLab API client: %v", err)
}
- tm := transaction.NewManager(cfg)
- prometheus.MustRegister(tm)
- hm := hook.NewManager(config.NewLocator(cfg), tm, gitlabAPI, cfg)
+ hm := hook.NewManager(config.NewLocator(cfg), transactionManager, gitlabAPI, cfg)
hookManager = hm
}
@@ -150,7 +152,7 @@ func run(cfg config.Cfg, b *bootstrap.Bootstrap) error {
)
defer conns.Close()
- servers := server.NewGitalyServerFactory(cfg, hookManager, conns)
+ servers := server.NewGitalyServerFactory(cfg, hookManager, transactionManager, conns)
defer servers.Stop()
b.StopAction = servers.GracefulStop
diff --git a/internal/gitaly/maintenance/optimize_test.go b/internal/gitaly/maintenance/optimize_test.go
index 85419dd2d..02e1745ed 100644
--- a/internal/gitaly/maintenance/optimize_test.go
+++ b/internal/gitaly/maintenance/optimize_test.go
@@ -11,6 +11,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/repository"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
@@ -27,7 +28,7 @@ func (mo *mockOptimizer) OptimizeRepository(ctx context.Context, req *gitalypb.O
cfg := config.Cfg{Storages: mo.storages}
l := config.NewLocator(cfg)
gitCmdFactory := git.NewExecCommandFactory(cfg)
- resp, err := repository.NewServer(cfg, nil, l, gitCmdFactory).OptimizeRepository(ctx, req)
+ resp, err := repository.NewServer(cfg, nil, l, transaction.NewManager(cfg), gitCmdFactory).OptimizeRepository(ctx, req)
assert.NoError(mo.t, err)
return resp, err
}
diff --git a/internal/gitaly/server/auth_test.go b/internal/gitaly/server/auth_test.go
index 45aac32c5..7d89be5b6 100644
--- a/internal/gitaly/server/auth_test.go
+++ b/internal/gitaly/server/auth_test.go
@@ -202,7 +202,8 @@ func newOperationClient(t *testing.T, serverSocketPath string) (gitalypb.Operati
func runServerWithRuby(t *testing.T, ruby *rubyserver.Server) (string, func()) {
conns := client.NewPool()
- srv := NewInsecure(ruby, hook.NewManager(config.NewLocator(config.Config), transaction.NewManager(config.Config), hook.GitlabAPIStub, config.Config), config.Config, conns)
+ txManager := transaction.NewManager(config.Config)
+ srv := NewInsecure(ruby, hook.NewManager(config.NewLocator(config.Config), txManager, hook.GitlabAPIStub, config.Config), txManager, config.Config, conns)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName(t)
@@ -229,7 +230,7 @@ func runSecureServer(t *testing.T) (string, func()) {
}
conns := client.NewPool()
- srv := NewSecure(nil, nil, config.Config, conns)
+ srv := NewSecure(nil, nil, nil, config.Config, conns)
listener, hostPort := testhelper.GetLocalhostListener(t)
go srv.Serve(listener)
diff --git a/internal/gitaly/server/server.go b/internal/gitaly/server/server.go
index 532d14d47..578f11ee8 100644
--- a/internal/gitaly/server/server.go
+++ b/internal/gitaly/server/server.go
@@ -18,6 +18,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/gitaly/rubyserver"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/server/auth"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/helper/fieldextractors"
gitalylog "gitlab.com/gitlab-org/gitaly/internal/log"
"gitlab.com/gitlab-org/gitaly/internal/logsanitizer"
@@ -75,7 +76,7 @@ func init() {
// createNewServer returns a GRPC server with all Gitaly services and interceptors set up.
// allows for specifying secure = true to enable tls credentials
-func createNewServer(rubyServer *rubyserver.Server, hookManager hook.Manager, cfg config.Cfg, secure bool, conns *client.Pool) *grpc.Server {
+func createNewServer(rubyServer *rubyserver.Server, hookManager hook.Manager, txManager transaction.Manager, cfg config.Cfg, secure bool, conns *client.Pool) *grpc.Server {
ctxTagOpts := []grpc_ctxtags.Option{
grpc_ctxtags.WithFieldExtractorForInitialReq(fieldextractors.FieldExtractor),
}
@@ -142,7 +143,7 @@ func createNewServer(rubyServer *rubyserver.Server, hookManager hook.Manager, cf
server := grpc.NewServer(opts...)
- service.RegisterAll(server, cfg, rubyServer, hookManager, storageLocator, conns, git.NewExecCommandFactory(cfg))
+ service.RegisterAll(server, cfg, rubyServer, hookManager, txManager, storageLocator, conns, git.NewExecCommandFactory(cfg))
reflection.Register(server)
grpc_prometheus.Register(server)
@@ -151,11 +152,11 @@ func createNewServer(rubyServer *rubyserver.Server, hookManager hook.Manager, cf
}
// NewInsecure returns a GRPC server with all Gitaly services and interceptors set up.
-func NewInsecure(rubyServer *rubyserver.Server, hookManager hook.Manager, cfg config.Cfg, conns *client.Pool) *grpc.Server {
- return createNewServer(rubyServer, hookManager, cfg, false, conns)
+func NewInsecure(rubyServer *rubyserver.Server, hookManager hook.Manager, txManager transaction.Manager, cfg config.Cfg, conns *client.Pool) *grpc.Server {
+ return createNewServer(rubyServer, hookManager, txManager, cfg, false, conns)
}
// NewSecure returns a GRPC server enabling TLS credentials
-func NewSecure(rubyServer *rubyserver.Server, hookManager hook.Manager, cfg config.Cfg, conns *client.Pool) *grpc.Server {
- return createNewServer(rubyServer, hookManager, cfg, true, conns)
+func NewSecure(rubyServer *rubyserver.Server, hookManager hook.Manager, txManager transaction.Manager, cfg config.Cfg, conns *client.Pool) *grpc.Server {
+ return createNewServer(rubyServer, hookManager, txManager, cfg, true, conns)
}
diff --git a/internal/gitaly/server/server_factory.go b/internal/gitaly/server/server_factory.go
index 78f1cc3b6..ccf4f40ea 100644
--- a/internal/gitaly/server/server_factory.go
+++ b/internal/gitaly/server/server_factory.go
@@ -14,6 +14,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/gitaly/hook"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/maintenance"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/rubyserver"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
)
@@ -24,14 +25,21 @@ type GitalyServerFactory struct {
cfg config.Cfg
ruby *rubyserver.Server
hookManager hook.Manager
+ txManager transaction.Manager
secure, insecure []*grpc.Server
conns *client.Pool
}
// NewGitalyServerFactory allows to create and start secure/insecure 'grpc.Server'-s with gitaly-ruby
// server shared in between.
-func NewGitalyServerFactory(cfg config.Cfg, hookManager hook.Manager, conns *client.Pool) *GitalyServerFactory {
- return &GitalyServerFactory{cfg: cfg, ruby: &rubyserver.Server{}, hookManager: hookManager, conns: conns}
+func NewGitalyServerFactory(cfg config.Cfg, hookManager hook.Manager, txManager transaction.Manager, conns *client.Pool) *GitalyServerFactory {
+ return &GitalyServerFactory{
+ cfg: cfg,
+ ruby: &rubyserver.Server{},
+ hookManager: hookManager,
+ txManager: txManager,
+ conns: conns,
+ }
}
// StartRuby starts the ruby process
@@ -127,11 +135,11 @@ func (s *GitalyServerFactory) create(secure bool) *grpc.Server {
defer s.mtx.Unlock()
if secure {
- s.secure = append(s.secure, NewSecure(s.ruby, s.hookManager, s.cfg, s.conns))
+ s.secure = append(s.secure, NewSecure(s.ruby, s.hookManager, s.txManager, s.cfg, s.conns))
return s.secure[len(s.secure)-1]
}
- s.insecure = append(s.insecure, NewInsecure(s.ruby, s.hookManager, s.cfg, s.conns))
+ s.insecure = append(s.insecure, NewInsecure(s.ruby, s.hookManager, s.txManager, s.cfg, s.conns))
return s.insecure[len(s.insecure)-1]
}
diff --git a/internal/gitaly/server/server_factory_test.go b/internal/gitaly/server/server_factory_test.go
index 034479c29..ac24b0fee 100644
--- a/internal/gitaly/server/server_factory_test.go
+++ b/internal/gitaly/server/server_factory_test.go
@@ -81,7 +81,7 @@ func TestGitalyServerFactory(t *testing.T) {
}
t.Run("insecure", func(t *testing.T) {
- sf := NewGitalyServerFactory(config.Config, nil, nil)
+ sf := NewGitalyServerFactory(config.Config, nil, nil, nil)
_, cleanup := checkHealth(t, sf, starter.TCP, "localhost:0")
defer cleanup()
@@ -97,7 +97,7 @@ func TestGitalyServerFactory(t *testing.T) {
KeyPath: keyFile,
}
- sf := NewGitalyServerFactory(config.Config, nil, nil)
+ sf := NewGitalyServerFactory(config.Config, nil, nil, nil)
defer sf.Stop()
_, cleanup := checkHealth(t, sf, starter.TLS, "localhost:0")
@@ -105,7 +105,7 @@ func TestGitalyServerFactory(t *testing.T) {
})
t.Run("all services must be stopped", func(t *testing.T) {
- sf := NewGitalyServerFactory(config.Config, nil, nil)
+ sf := NewGitalyServerFactory(config.Config, nil, nil, nil)
defer sf.Stop()
tcpHealthClient, tcpCleanup := checkHealth(t, sf, starter.TCP, "localhost:0")
diff --git a/internal/gitaly/service/conflicts/resolve_conflicts_test.go b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
index 7f36535ab..4a5aaac08 100644
--- a/internal/gitaly/service/conflicts/resolve_conflicts_test.go
+++ b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
@@ -14,6 +14,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
serverPkg "gitlab.com/gitlab-org/gitaly/internal/gitaly/server"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/conflicts"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -419,7 +420,7 @@ func testFailedResolveConflictsRequestDueToValidation(t *testing.T, ctx context.
func runFullServer(t *testing.T) (string, func()) {
conns := client.NewPool()
- server := serverPkg.NewInsecure(conflicts.RubyServer, nil, config.Config, conns)
+ server := serverPkg.NewInsecure(conflicts.RubyServer, nil, transaction.NewManager(config.Config), config.Config, conns)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName(t)
listener, err := net.Listen("unix", serverSocketPath)
diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go
index c74e2a8e1..20a2d9921 100644
--- a/internal/gitaly/service/operations/testhelper_test.go
+++ b/internal/gitaly/service/operations/testhelper_test.go
@@ -90,7 +90,7 @@ func runOperationServiceServerWithRubyServer(t *testing.T, ruby *rubyserver.Serv
gitalypb.RegisterOperationServiceServer(srv.GrpcServer(), server)
gitalypb.RegisterHookServiceServer(srv.GrpcServer(), hook.NewServer(config.Config, hookManager))
- gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), repository.NewServer(config.Config, ruby, locator, gitCmdFactory))
+ gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), repository.NewServer(config.Config, ruby, locator, txManager, gitCmdFactory))
gitalypb.RegisterRefServiceServer(srv.GrpcServer(), ref.NewServer(config.Config, locator))
gitalypb.RegisterCommitServiceServer(srv.GrpcServer(), commit.NewServer(config.Config, locator))
gitalypb.RegisterSSHServiceServer(srv.GrpcServer(), ssh.NewServer(config.Config, locator, gitCmdFactory))
diff --git a/internal/gitaly/service/register.go b/internal/gitaly/service/register.go
index f84343233..398d00fed 100644
--- a/internal/gitaly/service/register.go
+++ b/internal/gitaly/service/register.go
@@ -27,6 +27,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/smarthttp"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/ssh"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/wiki"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
@@ -65,7 +66,16 @@ func registerMetrics(cfg config.Cfg) {
// RegisterAll will register all the known grpc services with
// the specified grpc service instance
-func RegisterAll(grpcServer *grpc.Server, cfg config.Cfg, rubyServer *rubyserver.Server, hookManager gitalyhook.Manager, locator storage.Locator, conns *client.Pool, gitCmdFactory git.CommandFactory) {
+func RegisterAll(
+ grpcServer *grpc.Server,
+ cfg config.Cfg,
+ rubyServer *rubyserver.Server,
+ hookManager gitalyhook.Manager,
+ txManager transaction.Manager,
+ locator storage.Locator,
+ conns *client.Pool,
+ gitCmdFactory git.CommandFactory,
+) {
once.Do(func() {
registerMetrics(cfg)
})
@@ -77,7 +87,7 @@ func RegisterAll(grpcServer *grpc.Server, cfg config.Cfg, rubyServer *rubyserver
gitalypb.RegisterNamespaceServiceServer(grpcServer, namespace.NewServer(locator))
gitalypb.RegisterOperationServiceServer(grpcServer, operations.NewServer(cfg, rubyServer, hookManager, locator, conns, git.NewExecCommandFactory(cfg)))
gitalypb.RegisterRefServiceServer(grpcServer, ref.NewServer(cfg, locator))
- gitalypb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(cfg, rubyServer, locator, gitCmdFactory))
+ gitalypb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(cfg, rubyServer, locator, txManager, gitCmdFactory))
gitalypb.RegisterSSHServiceServer(grpcServer, ssh.NewServer(
cfg,
locator,
diff --git a/internal/gitaly/service/remote/fetch_internal_remote_test.go b/internal/gitaly/service/remote/fetch_internal_remote_test.go
index ae205338c..43b5943c8 100644
--- a/internal/gitaly/service/remote/fetch_internal_remote_test.go
+++ b/internal/gitaly/service/remote/fetch_internal_remote_test.go
@@ -13,6 +13,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/ref"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/remote"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/ssh"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/helper"
"gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -176,7 +177,7 @@ func TestFailedFetchInternalRemoteDueToValidations(t *testing.T) {
func runFullServer(t *testing.T) (string, func()) {
conns := client.NewPool()
- server := serverPkg.NewInsecure(remote.RubyServer, nil, config.Config, conns)
+ server := serverPkg.NewInsecure(remote.RubyServer, nil, transaction.NewManager(config.Config), config.Config, conns)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName(t)
listener, err := net.Listen("unix", serverSocketPath)
diff --git a/internal/gitaly/service/repository/fetch_test.go b/internal/gitaly/service/repository/fetch_test.go
index e8f69cd52..1d4a8666d 100644
--- a/internal/gitaly/service/repository/fetch_test.go
+++ b/internal/gitaly/service/repository/fetch_test.go
@@ -335,7 +335,7 @@ func runFullServer(t *testing.T, locator storage.Locator) (string, func()) {
txManager := transaction.NewManager(config.Config)
hookManager := hook.NewManager(locator, txManager, hook.GitlabAPIStub, config.Config)
- server := serverPkg.NewInsecure(repository.RubyServer, hookManager, config.Config, conns)
+ server := serverPkg.NewInsecure(repository.RubyServer, hookManager, txManager, config.Config, conns)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName(t)
@@ -360,7 +360,7 @@ func runFullSecureServer(t *testing.T, locator storage.Locator) (*grpc.Server, s
txManager := transaction.NewManager(config.Config)
hookManager := hook.NewManager(locator, txManager, hook.GitlabAPIStub, config.Config)
- server := serverPkg.NewSecure(repository.RubyServer, hookManager, config.Config, conns)
+ server := serverPkg.NewSecure(repository.RubyServer, hookManager, txManager, config.Config, conns)
listener, addr := testhelper.GetLocalhostListener(t)
errQ := make(chan error)
diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go
index d129ebebd..ddc0ddebc 100644
--- a/internal/gitaly/service/repository/replicate_test.go
+++ b/internal/gitaly/service/repository/replicate_test.go
@@ -14,6 +14,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/repository"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -366,7 +367,7 @@ func runServerWithBadFetchInternalRemote(t *testing.T) (*grpc.Server, string) {
internalListener, err := net.Listen("unix", config.Config.GitalyInternalSocketPath())
require.NoError(t, err)
- gitalypb.RegisterRepositoryServiceServer(server, repository.NewServer(config.Config, repository.RubyServer, config.NewLocator(config.Config), git.NewExecCommandFactory(config.Config)))
+ gitalypb.RegisterRepositoryServiceServer(server, repository.NewServer(config.Config, repository.RubyServer, config.NewLocator(config.Config), transaction.NewManager(config.Config), git.NewExecCommandFactory(config.Config)))
gitalypb.RegisterRemoteServiceServer(server, &mockRemoteServer{})
reflection.Register(server)
diff --git a/internal/gitaly/service/repository/search_files_test.go b/internal/gitaly/service/repository/search_files_test.go
index 98d957c0d..522e1bc13 100644
--- a/internal/gitaly/service/repository/search_files_test.go
+++ b/internal/gitaly/service/repository/search_files_test.go
@@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc/codes"
@@ -213,7 +214,7 @@ func TestSearchFilesByContentLargeFile(t *testing.T) {
}
func TestSearchFilesByContentFailure(t *testing.T) {
- server := NewServer(config.Config, RubyServer, config.NewLocator(config.Config), git.NewExecCommandFactory(config.Config))
+ server := NewServer(config.Config, RubyServer, config.NewLocator(config.Config), transaction.NewManager(config.Config), git.NewExecCommandFactory(config.Config))
testRepo, _, cleanupRepo := testhelper.NewTestRepo(t)
defer cleanupRepo()
@@ -335,7 +336,7 @@ func TestSearchFilesByNameSuccessful(t *testing.T) {
}
func TestSearchFilesByNameFailure(t *testing.T) {
- server := NewServer(config.Config, RubyServer, config.NewLocator(config.Config), git.NewExecCommandFactory(config.Config))
+ server := NewServer(config.Config, RubyServer, config.NewLocator(config.Config), transaction.NewManager(config.Config), git.NewExecCommandFactory(config.Config))
testCases := []struct {
desc string
diff --git a/internal/gitaly/service/repository/server.go b/internal/gitaly/service/repository/server.go
index dd29fac52..b73e29047 100644
--- a/internal/gitaly/service/repository/server.go
+++ b/internal/gitaly/service/repository/server.go
@@ -5,6 +5,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/rubyserver"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
@@ -13,6 +14,7 @@ type server struct {
ruby *rubyserver.Server
conns *client.Pool
locator storage.Locator
+ txManager transaction.Manager
gitCmdFactory git.CommandFactory
cfg config.Cfg
binDir string
@@ -20,10 +22,17 @@ type server struct {
}
// NewServer creates a new instance of a gRPC repo server
-func NewServer(cfg config.Cfg, rs *rubyserver.Server, locator storage.Locator, gitCmdFactory git.CommandFactory) gitalypb.RepositoryServiceServer {
+func NewServer(
+ cfg config.Cfg,
+ rs *rubyserver.Server,
+ locator storage.Locator,
+ txManager transaction.Manager,
+ gitCmdFactory git.CommandFactory,
+) gitalypb.RepositoryServiceServer {
return &server{
ruby: rs,
locator: locator,
+ txManager: txManager,
gitCmdFactory: gitCmdFactory,
conns: client.NewPoolWithOptions(
client.WithDialer(client.HealthCheckDialer(client.DialContext)),
diff --git a/internal/gitaly/service/repository/testhelper_test.go b/internal/gitaly/service/repository/testhelper_test.go
index 291db9e96..1a596412b 100644
--- a/internal/gitaly/service/repository/testhelper_test.go
+++ b/internal/gitaly/service/repository/testhelper_test.go
@@ -115,7 +115,7 @@ func runRepoServerWithConfig(t *testing.T, cfg config.Cfg, locator storage.Locat
hookManager := hook.NewManager(locator, txManager, hook.GitlabAPIStub, cfg)
srv := testhelper.NewServerWithAuth(t, streamInt, unaryInt, cfg.Auth.Token, opts...)
- gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), NewServer(cfg, RubyServer, locator, git.NewExecCommandFactory(config.Config)))
+ gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), NewServer(cfg, RubyServer, locator, txManager, git.NewExecCommandFactory(config.Config)))
gitalypb.RegisterHookServiceServer(srv.GrpcServer(), hookservice.NewServer(config.Config, hookManager))
srv.Start(t)
diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go
index b5ff3ed38..4c0bccb4a 100644
--- a/internal/praefect/replicator_test.go
+++ b/internal/praefect/replicator_test.go
@@ -1005,7 +1005,7 @@ func runFullGitalyServer(t *testing.T) (string, func()) {
conns := client.NewPool()
txManager := transaction.NewManager(gitaly_config.Config)
hookManager := hook.NewManager(gitaly_config.NewLocator(gitaly_config.Config), txManager, hook.GitlabAPIStub, gitaly_config.Config)
- server := serverPkg.NewInsecure(RubyServer, hookManager, gitaly_config.Config, conns)
+ server := serverPkg.NewInsecure(RubyServer, hookManager, txManager, gitaly_config.Config, conns)
serverSocketPath := testhelper.GetTemporaryGitalySocketFileName(t)
@@ -1036,8 +1036,10 @@ func newReplicationService(tb testing.TB) (*grpc.Server, string) {
svr := testhelper.NewTestGrpcServer(tb, nil, nil)
locator := gitaly_config.NewLocator(gitaly_config.Config)
+ txManager := transaction.NewManager(gitaly_config.Config)
gitCmdFactory := git.NewExecCommandFactory(gitaly_config.Config)
- gitalypb.RegisterRepositoryServiceServer(svr, repository.NewServer(gitaly_config.Config, RubyServer, locator, gitCmdFactory))
+
+ gitalypb.RegisterRepositoryServiceServer(svr, repository.NewServer(gitaly_config.Config, RubyServer, locator, txManager, gitCmdFactory))
gitalypb.RegisterObjectPoolServiceServer(svr, objectpoolservice.NewServer(gitaly_config.Config, locator, gitCmdFactory))
gitalypb.RegisterRemoteServiceServer(svr, remote.NewServer(gitaly_config.Config, RubyServer, locator, gitCmdFactory))
gitalypb.RegisterSSHServiceServer(svr, ssh.NewServer(gitaly_config.Config, locator, gitCmdFactory))
diff --git a/internal/praefect/server_factory_test.go b/internal/praefect/server_factory_test.go
index f8ff2823a..7c13e0b23 100644
--- a/internal/praefect/server_factory_test.go
+++ b/internal/praefect/server_factory_test.go
@@ -30,7 +30,7 @@ import (
)
func TestServerFactory(t *testing.T) {
- gitalyServerFactory := server.NewGitalyServerFactory(gconfig.Config, nil, nil)
+ gitalyServerFactory := server.NewGitalyServerFactory(gconfig.Config, nil, nil, nil)
defer gitalyServerFactory.Stop()
// start gitaly serving on public endpoint
diff --git a/internal/praefect/service/info/consistencycheck_test.go b/internal/praefect/service/info/consistencycheck_test.go
index 1a8fd565f..699045d68 100644
--- a/internal/praefect/service/info/consistencycheck_test.go
+++ b/internal/praefect/service/info/consistencycheck_test.go
@@ -14,6 +14,7 @@ import (
gconfig "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/internalgitaly"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/repository"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/praefect/config"
"gitlab.com/gitlab-org/gitaly/internal/praefect/datastore"
"gitlab.com/gitlab-org/gitaly/internal/praefect/nodes"
@@ -67,7 +68,7 @@ func TestServer_ConsistencyCheck(t *testing.T) {
gitalySrv := grpc.NewServer()
defer gitalySrv.Stop()
- gitalypb.RegisterRepositoryServiceServer(gitalySrv, repository.NewServer(gconfig.Config, nil, gconfig.NewLocator(gconfig.Config), git.NewExecCommandFactory(gconfig.Config)))
+ gitalypb.RegisterRepositoryServiceServer(gitalySrv, repository.NewServer(gconfig.Config, nil, gconfig.NewLocator(gconfig.Config), transaction.NewManager(gconfig.Config), git.NewExecCommandFactory(gconfig.Config)))
gitalypb.RegisterInternalGitalyServer(gitalySrv, internalgitaly.NewServer(gconfig.Config.Storages))
go func() { gitalySrv.Serve(gitalyListener) }()
}
diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go
index e33e0d467..6d7de7361 100644
--- a/internal/testhelper/testserver/gitaly.go
+++ b/internal/testhelper/testserver/gitaly.go
@@ -14,6 +14,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/internalgitaly"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/repository"
gitalyserver "gitlab.com/gitlab-org/gitaly/internal/gitaly/service/server"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc"
@@ -45,6 +46,7 @@ func registerGitalyServices(server *grpc.Server, pg PartialGitaly) {
// Gitaly services.
func RealGitaly(storages []config.Storage, authToken, internalSocketPath string) PartialGitaly {
locator := config.NewLocator(config.Config)
+ transactionManager := transaction.NewManager(config.Config)
gitCmdFactory := git.NewExecCommandFactory(config.Config)
return struct {
gitalypb.ServerServiceServer
@@ -54,7 +56,7 @@ func RealGitaly(storages []config.Storage, authToken, internalSocketPath string)
healthpb.HealthServer
}{
gitalyserver.NewServer(storages),
- repository.NewServer(config.Config, RubyServer, locator, gitCmdFactory),
+ repository.NewServer(config.Config, RubyServer, locator, transactionManager, gitCmdFactory),
internalgitaly.NewServer(config.Config.Storages),
commit.NewServer(config.Config, locator),
health.NewServer(),