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-09-24 13:46:10 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2021-09-24 13:46:10 +0300
commit134d9413baff9bbed84406b6a06d2f28ee16ffd0 (patch)
treeca9703d54baef00415996569dee873c69b7f1de7 /internal
parent5b5d235cc38a38f1b56865f9d2b8bc83411bf1fc (diff)
Don't use forceCreateRepositories hack for repo creations
Repository creations fail with Praefect in tests due to the testing hack that creates repository records. As the hack creates a record for the repository before the actual call is executed, the actual call will fail with 'repository exists'. This commit worksaround the problem by not using the hack for repository creation calls. Ideally we would not have such a hack in the first place and would use the API to create the repositories in the tests.
Diffstat (limited to 'internal')
-rw-r--r--internal/praefect/coordinator.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/internal/praefect/coordinator.go b/internal/praefect/coordinator.go
index 938f47fe7..0cfc43782 100644
--- a/internal/praefect/coordinator.go
+++ b/internal/praefect/coordinator.go
@@ -331,20 +331,27 @@ func (c *Coordinator) directRepositoryScopedMessage(ctx context.Context, call gr
var ps *proxy.StreamParameters
if c.forceCreateRepositories {
- // This is a hack for the tests: during execution of the gitaly tests under praefect proxy
- // the repositories are created directly on the filesystem. There is no call for the
- // CreateRepository that creates records in the database that is why we do it artificially
- // before redirecting the calls.
- id, err := c.rs.ReserveRepositoryID(ctx, call.targetRepo.StorageName, call.targetRepo.RelativePath)
+ replicationType, _, err := getReplicationDetails(call.fullMethodName, call.msg)
if err != nil {
- if !errors.Is(err, commonerr.ErrRepositoryAlreadyExists) {
- return nil, err
- }
- } else {
- if err := c.rs.CreateRepository(ctx, id, call.targetRepo.StorageName, call.targetRepo.RelativePath, call.targetRepo.StorageName, nil, nil, true, true); err != nil {
- if !errors.As(err, &datastore.RepositoryExistsError{}) {
+ return nil, err
+ }
+
+ if replicationType != datastore.CreateRepo {
+ // This is a hack for the tests: during execution of the gitaly tests under praefect proxy
+ // the repositories are created directly on the filesystem. There is no call for the
+ // CreateRepository that creates records in the database that is why we do it artificially
+ // before redirecting the calls.
+ id, err := c.rs.ReserveRepositoryID(ctx, call.targetRepo.StorageName, call.targetRepo.RelativePath)
+ if err != nil {
+ if !errors.Is(err, commonerr.ErrRepositoryAlreadyExists) {
return nil, err
}
+ } else {
+ if err := c.rs.CreateRepository(ctx, id, call.targetRepo.StorageName, call.targetRepo.RelativePath, call.targetRepo.StorageName, nil, nil, true, true); err != nil {
+ if !errors.As(err, &datastore.RepositoryExistsError{}) {
+ return nil, err
+ }
+ }
}
}
}