diff options
author | Igor Drozdov <idrozdov@gitlab.com> | 2021-10-20 11:34:10 +0300 |
---|---|---|
committer | Igor Drozdov <idrozdov@gitlab.com> | 2021-10-20 12:02:09 +0300 |
commit | 1dede51df96e9524b5519e115db5a0e1c719d03b (patch) | |
tree | a1b8f405c57df8ede0b85c14fc71eef4f79ede06 /internal/handler/exec.go | |
parent | f9f5423cf8d65c97d42991e218b990e5132fe293 (diff) | |
download | gitlab-shell-id-logging-for-handler.tar.gz |
Add logging to RunGitalyCommand funcid-logging-for-handler
Diffstat (limited to 'internal/handler/exec.go')
-rw-r--r-- | internal/handler/exec.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/internal/handler/exec.go b/internal/handler/exec.go index 172736d..8f4a7df 100644 --- a/internal/handler/exec.go +++ b/internal/handler/exec.go @@ -45,17 +45,24 @@ type GitalyCommand struct { func (gc *GitalyCommand) RunGitalyCommand(ctx context.Context, handler GitalyHandlerFunc) error { conn, err := getConn(ctx, gc) if err != nil { + log.ContextLogger(ctx).WithError(fmt.Errorf("RunGitalyCommand: %v", err)).Error("Failed to get connection to execute Git command") + return err } defer conn.Close() childCtx := withOutgoingMetadata(ctx, gc.Features) - _, err = handler(childCtx, conn) + ctxlog := log.ContextLogger(childCtx) + exitStatus, err := handler(childCtx, conn) + + if err != nil { + if grpcstatus.Convert(err).Code() == grpccodes.Unavailable { + ctxlog.WithError(fmt.Errorf("RunGitalyCommand: %v", err)).Error("Gitaly is unavailable") - if err != nil && grpcstatus.Convert(err).Code() == grpccodes.Unavailable { - log.WithError(err).Error("Gitaly is unavailable") + return fmt.Errorf("The git server, Gitaly, is not available at this time. Please contact your administrator.") + } - return fmt.Errorf("Git service is temporarily unavailable") + ctxlog.WithError(err).WithFields(log.Fields{"exit_status": exitStatus}).Error("Failed to execute Git command") } return err |