Skip to content

Commit 3a8bab4

Browse files
author
Will Chandler
committed
Suppress internal errors in client output
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.
1 parent 3038ae4 commit 3a8bab4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cmd/gitlab-shell/main.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import (
55
"os"
66
"reflect"
77

8+
grpccodes "google.golang.org/grpc/codes"
9+
grpcstatus "google.golang.org/grpc/status"
10+
811
"gitlab.com/gitlab-org/labkit/log"
912

1013
shellCmd "gitlab.com/gitlab-org/gitlab-shell/cmd/gitlab-shell/command"
@@ -71,7 +74,9 @@ func main() {
7174

7275
if err := cmd.Execute(ctx); err != nil {
7376
ctxlog.WithError(err).Warn("gitlab-shell: main: command execution failed")
74-
console.DisplayWarningMessage(err.Error(), readWriter.ErrOut)
77+
if grpcstatus.Convert(err).Code() != grpccodes.Internal {
78+
console.DisplayWarningMessage(err.Error(), readWriter.ErrOut)
79+
}
7580
os.Exit(1)
7681
}
7782

0 commit comments

Comments
 (0)