Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Wiedler <iwiedler@gitlab.com>2022-07-18 16:51:23 +0300
committerIgor Wiedler <iwiedler@gitlab.com>2022-07-18 18:09:35 +0300
commit756146ba4f4c47283c44a1bceb64e2017a2f7d35 (patch)
tree30bd79fa800f733109dd223dedb065a36d1d029b
parenta454dd8c911101edb4d1d7b8218301584ea199e7 (diff)
Classify "the remote end hung up" as Canceled instead of Internalremote-end-hung-up-aborted
-rw-r--r--internal/gitaly/service/ssh/upload_pack.go6
-rw-r--r--internal/gitaly/service/ssh/upload_pack_test.go2
-rw-r--r--internal/helper/error.go6
3 files changed, 12 insertions, 2 deletions
diff --git a/internal/gitaly/service/ssh/upload_pack.go b/internal/gitaly/service/ssh/upload_pack.go
index 89e67e9a9..7d9094489 100644
--- a/internal/gitaly/service/ssh/upload_pack.go
+++ b/internal/gitaly/service/ssh/upload_pack.go
@@ -151,7 +151,11 @@ func (s *server) sshUploadPack(ctx context.Context, req sshUploadPackRequest, st
if err := cmd.Wait(); err != nil {
status, _ := command.ExitStatus(err)
- return status, fmt.Errorf("cmd wait: %w, stderr: %q", err, stderrBuilder.String())
+ err = fmt.Errorf("cmd wait: %w, stderr: %q", err, stderrBuilder.String())
+ if strings.Contains(stderrBuilder.String(), "fatal: the remote end hung up unexpectedly") {
+ err = helper.ErrCanceled(err)
+ }
+ return status, err
}
ctxlogrus.Extract(ctx).WithField("response_bytes", stdoutCounter.N).Info("request details")
diff --git a/internal/gitaly/service/ssh/upload_pack_test.go b/internal/gitaly/service/ssh/upload_pack_test.go
index 3739d2617..81d31d9ee 100644
--- a/internal/gitaly/service/ssh/upload_pack_test.go
+++ b/internal/gitaly/service/ssh/upload_pack_test.go
@@ -273,7 +273,7 @@ func TestUploadPackWithSidechannel_client(t *testing.T) {
return nil
},
- expectedErr: helper.ErrInternalf("cmd wait: exit status 128, stderr: %q", "fatal: the remote end hung up unexpectedly\n"),
+ expectedErr: helper.ErrCanceledf("cmd wait: exit status 128, stderr: %q", "fatal: the remote end hung up unexpectedly\n"),
},
{
desc: "garbage",
diff --git a/internal/helper/error.go b/internal/helper/error.go
index e649e5231..517fb1d70 100644
--- a/internal/helper/error.go
+++ b/internal/helper/error.go
@@ -60,6 +60,12 @@ func wrapError(code codes.Code, err error) error {
return err
}
+// ErrCanceledf wraps a formatted error with codes.Canceled, unless the formatted error is a
+// wrapped gRPC error.
+func ErrCanceledf(format string, a ...interface{}) error {
+ return formatError(codes.Canceled, format, a...)
+}
+
// ErrInternalf wraps a formatted error with codes.Internal, unless the formatted error is a
// wrapped gRPC error.
func ErrInternalf(format string, a ...interface{}) error {