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:
authorJustin Tobler <jtobler@gitlab.com>2023-10-04 20:12:57 +0300
committerJustin Tobler <jtobler@gitlab.com>2023-10-04 20:12:57 +0300
commit0706c0928c2015d28f1568a7ffd5892567c7edb6 (patch)
tree220f735bd7d6b6b45871d329718e3ed8c283b3d7
parent3e0b54959f433192b6147792427fa4521e5724b5 (diff)
parentf6a5b42dc35197534a0f1675d090e957e31c7805 (diff)
Merge branch 'backup_skip_not_found' into 'master'
Skip restore when a backup is not found See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6433 Merged-by: Justin Tobler <jtobler@gitlab.com> Approved-by: Quang-Minh Nguyen <qmnguyen@gitlab.com> Approved-by: Justin Tobler <jtobler@gitlab.com> Co-authored-by: James Fargher <jfargher@gitlab.com>
-rw-r--r--internal/backup/backup.go12
-rw-r--r--internal/backup/backup_test.go9
2 files changed, 15 insertions, 6 deletions
diff --git a/internal/backup/backup.go b/internal/backup/backup.go
index a2b38fc58..dc2a4ff15 100644
--- a/internal/backup/backup.go
+++ b/internal/backup/backup.go
@@ -268,14 +268,14 @@ func (mgr *Manager) Restore(ctx context.Context, req *RestoreRequest) error {
var backup *Backup
if req.BackupID == "" {
backup, err = mgr.locator.FindLatest(ctx, req.VanityRepository)
- if err != nil {
- return fmt.Errorf("manager: %w", err)
- }
} else {
backup, err = mgr.locator.Find(ctx, req.VanityRepository, req.BackupID)
- if err != nil {
- return fmt.Errorf("manager: %w", err)
- }
+ }
+ switch {
+ case errors.Is(err, ErrDoesntExist):
+ return fmt.Errorf("manager: %w: %s", ErrSkipped, err.Error())
+ case err != nil:
+ return fmt.Errorf("manager: %w", err)
}
hash, err := git.ObjectHashByFormat(backup.ObjectFormat)
diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go
index 9b84cec55..d6c614e91 100644
--- a/internal/backup/backup_test.go
+++ b/internal/backup/backup_test.go
@@ -804,6 +804,15 @@ func TestManager_Restore_specific(t *testing.T) {
expectedErrAs error
}{
{
+ desc: "missing backup",
+ setup: func(tb testing.TB) (*gitalypb.Repository, *git.Checksum) {
+ repo, _ := gittest.CreateRepository(t, ctx, cfg)
+
+ return repo, nil
+ },
+ expectedErrAs: backup.ErrSkipped,
+ },
+ {
desc: "single incremental",
setup: func(tb testing.TB) (*gitalypb.Repository, *git.Checksum) {
repo, _ := gittest.CreateRepository(t, ctx, cfg)