diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-07-07 12:55:47 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-07-13 14:16:15 +0300 |
commit | 7ef6d88030fbfea11d0c603e40822eb9887ae89a (patch) | |
tree | 185244226cf55aebf8481b437dbb932a4140766a | |
parent | e97000ef789ac963308f2e61b5c4d14c2f556be7 (diff) |
repository: Improve error reporting for Repack RPCs
The errors reported in our Repack RPCs may not be wrapped and are
lacking breadcrumbs. Fix both issues by using `helper.ErrInternalf()`.
-rw-r--r-- | internal/gitaly/service/repository/repack.go | 4 | ||||
-rw-r--r-- | internal/gitaly/service/repository/repack_test.go | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/internal/gitaly/service/repository/repack.go b/internal/gitaly/service/repository/repack.go index a8d2460c8..66184ef1b 100644 --- a/internal/gitaly/service/repository/repack.go +++ b/internal/gitaly/service/repository/repack.go @@ -37,7 +37,7 @@ func (s *server) RepackFull(ctx context.Context, in *gitalypb.RepackFullRequest) repackCounter.WithLabelValues(fmt.Sprint(in.GetCreateBitmap())).Inc() if err := housekeeping.RepackObjects(ctx, repo, cfg); err != nil { - return nil, helper.ErrInternal(err) + return nil, helper.ErrInternalf("repacking objects: %w", err) } return &gitalypb.RepackFullResponse{}, nil @@ -57,7 +57,7 @@ func (s *server) RepackIncremental(ctx context.Context, in *gitalypb.RepackIncre repackCounter.WithLabelValues(fmt.Sprint(false)).Inc() if err := housekeeping.RepackObjects(ctx, repo, cfg); err != nil { - return nil, err + return nil, helper.ErrInternalf("repacking objects: %w", err) } return &gitalypb.RepackIncrementalResponse{}, nil diff --git a/internal/gitaly/service/repository/repack_test.go b/internal/gitaly/service/repository/repack_test.go index 6a90cbdb5..7f0b04dcb 100644 --- a/internal/gitaly/service/repository/repack_test.go +++ b/internal/gitaly/service/repository/repack_test.go @@ -118,12 +118,12 @@ func TestRepackIncrementalFailure(t *testing.T) { { desc: "invalid storage name", repo: &gitalypb.Repository{StorageName: "foo"}, - err: status.Error(codes.InvalidArgument, gitalyOrPraefect(`GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository")), + err: status.Error(codes.InvalidArgument, gitalyOrPraefect(`repacking objects: GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository")), }, { desc: "no storage name", repo: &gitalypb.Repository{RelativePath: "bar"}, - err: status.Error(codes.InvalidArgument, gitalyOrPraefect(`GetStorageByName: no such storage: ""`, "repo scoped: invalid Repository")), + err: status.Error(codes.InvalidArgument, gitalyOrPraefect(`repacking objects: GetStorageByName: no such storage: ""`, "repo scoped: invalid Repository")), }, { desc: "non-existing repo", @@ -131,7 +131,7 @@ func TestRepackIncrementalFailure(t *testing.T) { err: status.Error( codes.NotFound, gitalyOrPraefect( - fmt.Sprintf(`GetRepoPath: not a git repository: "%s/bar"`, cfg.Storages[0].Path), + fmt.Sprintf(`repacking objects: GetRepoPath: not a git repository: "%s/bar"`, cfg.Storages[0].Path), praefectErr, ), ), @@ -263,12 +263,12 @@ func TestRepackFullFailure(t *testing.T) { { desc: "invalid storage name", repo: &gitalypb.Repository{StorageName: "foo"}, - err: status.Error(codes.InvalidArgument, gitalyOrPraefect(`GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository")), + err: status.Error(codes.InvalidArgument, gitalyOrPraefect(`repacking objects: GetStorageByName: no such storage: "foo"`, "repo scoped: invalid Repository")), }, { desc: "no storage name", repo: &gitalypb.Repository{RelativePath: "bar"}, - err: status.Error(codes.InvalidArgument, gitalyOrPraefect(`GetStorageByName: no such storage: ""`, "repo scoped: invalid Repository")), + err: status.Error(codes.InvalidArgument, gitalyOrPraefect(`repacking objects: GetStorageByName: no such storage: ""`, "repo scoped: invalid Repository")), }, { desc: "non-existing repo", @@ -276,7 +276,7 @@ func TestRepackFullFailure(t *testing.T) { err: status.Error( codes.NotFound, gitalyOrPraefect( - fmt.Sprintf(`GetRepoPath: not a git repository: "%s/bar"`, cfg.Storages[0].Path), + fmt.Sprintf(`repacking objects: GetRepoPath: not a git repository: "%s/bar"`, cfg.Storages[0].Path), praefectErr, ), ), |