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>2023-10-31 19:36:23 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2023-12-05 14:25:54 +0300
commitd21e0def61cdbb32ad8ca3470a3abccb8db78253 (patch)
tree58c86f8e67ed88b2e65bfdd69ea268f5f5d5c2f8
parente5c3a2eba373fd0776f69d98d7c50de837582f67 (diff)
Enable transactions for CreateFork
This commit enables transactions for CreateFork. Tests asserting behavior with invalid state were updated as these lead to a failure to begin a transaction before the RPC handler is invoked.
-rw-r--r--internal/gitaly/service/repository/create_fork_test.go32
-rw-r--r--internal/gitaly/storage/storagemgr/middleware.go2
2 files changed, 25 insertions, 9 deletions
diff --git a/internal/gitaly/service/repository/create_fork_test.go b/internal/gitaly/service/repository/create_fork_test.go
index 955b7ab99..0afc19fc9 100644
--- a/internal/gitaly/service/repository/create_fork_test.go
+++ b/internal/gitaly/service/repository/create_fork_test.go
@@ -286,16 +286,22 @@ func TestCreateFork_targetExists(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
- desc string
- seed func(t *testing.T, targetPath string)
- expectedErrWithAtomicCreation error
+ desc string
+ seed func(t *testing.T, targetPath string)
+ expectedErr error
}{
{
desc: "empty target directory",
seed: func(t *testing.T, targetPath string) {
require.NoError(t, os.MkdirAll(targetPath, perm.GroupPrivateDir))
},
- expectedErrWithAtomicCreation: structerr.NewAlreadyExists("creating fork: repository exists already"),
+ expectedErr: func() error {
+ if testhelper.IsWALEnabled() {
+ return structerr.NewInternal("begin transaction: get partition: get partition ID: validate git directory: invalid git directory")
+ }
+
+ return structerr.NewAlreadyExists("creating fork: repository exists already")
+ }(),
},
{
desc: "non-empty target directory",
@@ -307,7 +313,13 @@ func TestCreateFork_targetExists(t *testing.T) {
perm.SharedFile,
))
},
- expectedErrWithAtomicCreation: structerr.NewAlreadyExists("creating fork: repository exists already"),
+ expectedErr: func() error {
+ if testhelper.IsWALEnabled() {
+ return structerr.NewInternal("begin transaction: get partition: get partition ID: validate git directory: invalid git directory")
+ }
+
+ return structerr.NewAlreadyExists("creating fork: repository exists already")
+ }(),
},
{
desc: "target file",
@@ -315,7 +327,13 @@ func TestCreateFork_targetExists(t *testing.T) {
require.NoError(t, os.MkdirAll(filepath.Dir(targetPath), perm.GroupPrivateDir))
require.NoError(t, os.WriteFile(targetPath, nil, perm.SharedFile))
},
- expectedErrWithAtomicCreation: structerr.NewAlreadyExists("creating fork: repository exists already"),
+ expectedErr: func() error {
+ if testhelper.IsWALEnabled() {
+ return structerr.NewInternal("begin transaction: get partition: get partition ID: validate git directory: not a directory")
+ }
+
+ return structerr.NewAlreadyExists("creating fork: repository exists already")
+ }(),
},
} {
t.Run(tc.desc, func(t *testing.T) {
@@ -340,7 +358,7 @@ func TestCreateFork_targetExists(t *testing.T) {
Repository: forkedRepo,
SourceRepository: repo,
})
- testhelper.RequireGrpcError(t, tc.expectedErrWithAtomicCreation, err)
+ testhelper.RequireGrpcError(t, tc.expectedErr, err)
})
}
}
diff --git a/internal/gitaly/storage/storagemgr/middleware.go b/internal/gitaly/storage/storagemgr/middleware.go
index 02be60b81..4c78ede11 100644
--- a/internal/gitaly/storage/storagemgr/middleware.go
+++ b/internal/gitaly/storage/storagemgr/middleware.go
@@ -45,8 +45,6 @@ var NonTransactionalRPCs = map[string]struct{}{
"/gitaly.ObjectPoolService/LinkRepositoryToObjectPool": {},
"/gitaly.ObjectPoolService/DisconnectGitAlternates": {},
"/gitaly.ObjectPoolService/FetchIntoObjectPool": {},
- // CreateFork relies on object pools.
- "/gitaly.RepositoryService/CreateFork": {},
// ReplicateRepository is replicating the attributes and config which the
// WAL won't support. This is pending removal of their replication.