From 12ef6ced271cf06ac04534fbabb48539a9290c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 22 Jan 2021 16:32:17 +0100 Subject: Operations: log failed update-ref commands Do what we did in Ruby in 97a7930d6 (Update gitlab_git to 4a0f720a502ac02423, 2017-10-04) for numerous pure-Go calls. This is a more general solution to problem[1] brought up in the UserUpdateBranch MR[2]. 1. https://gitlab.com/gitlab-org/gitaly/-/merge_requests/3013#note_491544296 2. https://gitlab.com/gitlab-org/gitaly/-/merge_requests/3013 --- changelogs/unreleased/avar-log-update-ref-errors.yml | 5 +++++ internal/gitaly/service/operations/update_with_hooks.go | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/avar-log-update-ref-errors.yml diff --git a/changelogs/unreleased/avar-log-update-ref-errors.yml b/changelogs/unreleased/avar-log-update-ref-errors.yml new file mode 100644 index 000000000..6d206b165 --- /dev/null +++ b/changelogs/unreleased/avar-log-update-ref-errors.yml @@ -0,0 +1,5 @@ +--- +title: 'Operations: log failed update-ref commands' +merge_request: 3044 +author: +type: fixed diff --git a/internal/gitaly/service/operations/update_with_hooks.go b/internal/gitaly/service/operations/update_with_hooks.go index 2e2ce16e3..603fe4ee1 100644 --- a/internal/gitaly/service/operations/update_with_hooks.go +++ b/internal/gitaly/service/operations/update_with_hooks.go @@ -7,6 +7,7 @@ import ( "fmt" "strings" + "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/updateref" "gitlab.com/gitlab-org/gitaly/internal/gitaly/hook" @@ -93,11 +94,14 @@ func (s *Server) updateReferenceWithHooks(ctx context.Context, repo *gitalypb.Re return err } - if err := updater.Update(git.ReferenceName(reference), newrev, oldrev); err != nil { + referenceName := git.ReferenceName(reference) + if err := updater.Update(referenceName, newrev, oldrev); err != nil { + ctxlogrus.Extract(ctx).WithError(err).Errorf("'git update-ref' in %v failed with args (%v, %v, %v)", repo.GetGlProjectPath(), referenceName, newrev, oldrev) return err } if err := updater.Wait(); err != nil { + ctxlogrus.Extract(ctx).WithError(err).Errorf("'git update-ref' in %v failed on exit", repo.GetGlProjectPath()) return updateRefError{reference: reference} } -- cgit v1.2.3