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>2022-07-12 12:12:33 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-15 09:57:06 +0300
commit7edc0962187e2e8fe35bba2ca3ba02f893a00826 (patch)
treef6526165d5fb790a09d76d2ea42e23d2bb5c99ab
parent8c72787d912d6deda52ea90352e35950bc3f1e48 (diff)
objectpool: Improve error handling for FetchFromOrigin
Improve error handling in `FetchFromOrigin()` to provide proper breakcrumbs so that it becomes easier to see where a specific error has been raised. Furthermore, given that this is an internal package and not an RPC's implementation, we shouldn't wrap errors with error codes but instead leave this to the RPC implementations.
-rw-r--r--internal/git/objectpool/fetch.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/internal/git/objectpool/fetch.go b/internal/git/objectpool/fetch.go
index 549522809..3f05df31a 100644
--- a/internal/git/objectpool/fetch.go
+++ b/internal/git/objectpool/fetch.go
@@ -18,7 +18,6 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/updateref"
- "gitlab.com/gitlab-org/gitaly/v15/internal/helper"
)
const sourceRefNamespace = "refs/remotes/origin"
@@ -26,20 +25,20 @@ const sourceRefNamespace = "refs/remotes/origin"
// FetchFromOrigin initializes the pool and fetches the objects from its origin repository
func (o *ObjectPool) FetchFromOrigin(ctx context.Context, origin *localrepo.Repo) error {
if err := o.Init(ctx); err != nil {
- return err
+ return fmt.Errorf("initializing object pool: %w", err)
}
originPath, err := origin.Path()
if err != nil {
- return err
+ return fmt.Errorf("computing origin repo's path: %w", err)
}
if err := o.housekeepingManager.CleanStaleData(ctx, o.Repo); err != nil {
- return err
+ return fmt.Errorf("cleaning stale data: %w", err)
}
if err := o.logStats(ctx, "before fetch"); err != nil {
- return err
+ return fmt.Errorf("computing stats before fetch: %w", err)
}
refSpec := fmt.Sprintf("+refs/*:%s/*", sourceRefNamespace)
@@ -64,26 +63,30 @@ func (o *ObjectPool) FetchFromOrigin(ctx context.Context, origin *localrepo.Repo
git.WithRefTxHook(o.Repo),
git.WithStderr(&stderr),
); err != nil {
- return helper.ErrInternalf("fetch into object pool: %w, stderr: %q", err,
+ return fmt.Errorf("fetch into object pool: %w, stderr: %q", err,
stderr.String())
}
if err := o.rescueDanglingObjects(ctx); err != nil {
- return err
+ return fmt.Errorf("rescuing dangling objects: %w", err)
}
if err := o.logStats(ctx, "after fetch"); err != nil {
- return err
+ return fmt.Errorf("computing stats after fetch: %w", err)
}
if err := o.Repo.ExecAndWait(ctx, git.SubCmd{
Name: "pack-refs",
Flags: []git.Option{git.Flag{Name: "--all"}},
}); err != nil {
- return err
+ return fmt.Errorf("packing pool refs: %w", err)
}
- return o.repackPool(ctx, o)
+ if err := o.repackPool(ctx, o); err != nil {
+ return fmt.Errorf("repacking pool: %w", err)
+ }
+
+ return nil
}
const danglingObjectNamespace = "refs/dangling/"