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:
authorJames Fargher <jfargher@gitlab.com>2023-07-06 06:04:03 +0300
committerJames Fargher <jfargher@gitlab.com>2023-07-06 06:04:52 +0300
commit85ded50c9c07d87a93af5c37da692d165b5423d5 (patch)
tree31f3e7a0afba6741d89b9d0af74d5b09dc1c1d36
parentc29b5d0a215de1bf33a3315483b8dfcc0b1b53c2 (diff)
repository service: Hande restore skipped errorsrestore_repository_skipped
This is another edge-case caused by not differentiating between non-existent and empty repositories. In this case we need to handle not being able to find a backup bundle in which case we may skip, depending on AlwaysCreate. Ultimately this would be fixed by https://gitlab.com/gitlab-org/gitlab/-/issues/357044 Until then, it is useful to respond in a way that isn't successful and isn't a full blown failure.
-rw-r--r--internal/gitaly/service/repository/restore_repository.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/gitaly/service/repository/restore_repository.go b/internal/gitaly/service/repository/restore_repository.go
index 1cc20b2c7..a648d624c 100644
--- a/internal/gitaly/service/repository/restore_repository.go
+++ b/internal/gitaly/service/repository/restore_repository.go
@@ -2,6 +2,7 @@ package repository
import (
"context"
+ "errors"
"fmt"
"gitlab.com/gitlab-org/gitaly/v16/internal/backup"
@@ -28,11 +29,18 @@ func (s *server) RestoreRepository(ctx context.Context, in *gitalypb.RestoreRepo
in.GetBackupId(),
)
- if err := manager.Restore(ctx, &backup.RestoreRequest{
+ err := manager.Restore(ctx, &backup.RestoreRequest{
Repository: in.GetRepository(),
VanityRepository: in.GetVanityRepository(),
AlwaysCreate: in.GetAlwaysCreate(),
- }); err != nil {
+ })
+
+ switch {
+ case errors.Is(err, backup.ErrSkipped):
+ return nil, structerr.NewFailedPrecondition("restore repository: %w", err).WithDetail(
+ &gitalypb.RestoreRepositoryResponse_SkippedError{},
+ )
+ case err != nil:
return nil, structerr.NewInternal("restore repository: %w", err)
}