diff options
author | Will Chandler <wchandler@gitlab.com> | 2021-12-10 09:55:07 -0500 |
---|---|---|
committer | Will Chandler <wchandler@gitlab.com> | 2021-12-28 16:06:19 -0500 |
commit | 3a8bab437d8d0fd9bfa29bc5edd07ae5903af84d (patch) | |
tree | d4a9b058f6ed29b5f975e758a70f38c80178bfce /cmd/gitlab-shell/main.go | |
parent | 3038ae450383e63d9672f1b1d2f27995d2160bbc (diff) | |
download | gitlab-shell-wc-intern-err.tar.gz |
Suppress internal errors in client outputwc-intern-err
Until recently, Gitaly was silently swallowing any errors returned by
SSH `git upload-pack` processes. Clients would still receive stderr
output and a non-zero return code, but Gitlab-Shell would receive error
as nil and log success.
With 9deaf47f1ecb00f0f36d18ee4a0fb1576f5a0efe Gitaly will now return an
error when git fails, but this causes Gitlab-Shell to print out the
GRPC error code as a message to the client:
> fatal: couldn't find remote ref not-a-real-ref
> fatal: the remote end hung up unexpectedly
> remote:
> remote:
> ========================================================================
> remote:
> remote: rpc error: code = Internal desc = SSHUploadPack: exit status 128
> remote:
> remote:
> ========================================================================
> remote:
The `remote:` text gives no additional context for the user and adds
clutter.
This commit suppresses the additional message added by Gitlab-Shell on
failure when the error type is `Internal`, returning client output to
the format it was prior to the Gitaly change.
Diffstat (limited to 'cmd/gitlab-shell/main.go')
-rw-r--r-- | cmd/gitlab-shell/main.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/cmd/gitlab-shell/main.go b/cmd/gitlab-shell/main.go index a945d0c..693140d 100644 --- a/cmd/gitlab-shell/main.go +++ b/cmd/gitlab-shell/main.go @@ -5,6 +5,9 @@ import ( "os" "reflect" + grpccodes "google.golang.org/grpc/codes" + grpcstatus "google.golang.org/grpc/status" + "gitlab.com/gitlab-org/labkit/log" shellCmd "gitlab.com/gitlab-org/gitlab-shell/cmd/gitlab-shell/command" @@ -71,7 +74,9 @@ func main() { if err := cmd.Execute(ctx); err != nil { ctxlog.WithError(err).Warn("gitlab-shell: main: command execution failed") - console.DisplayWarningMessage(err.Error(), readWriter.ErrOut) + if grpcstatus.Convert(err).Code() != grpccodes.Internal { + console.DisplayWarningMessage(err.Error(), readWriter.ErrOut) + } os.Exit(1) } |