summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2022-06-06 10:09:00 -0700
committerStan Hu <stanhu@gmail.com>2022-06-06 10:09:00 -0700
commitb5de4796e71489278b623ab5b451b91ae07e4848 (patch)
treeb43b8bb92dd3094d3b00ea9eede671583c32c479
parent5085fe78c1b890a7fbe40430a55a08bd6b98d386 (diff)
downloadgitlab-shell-b5de4796e71489278b623ab5b451b91ae07e4848.tar.gz
Ignore "not our ref" errors from gitlab-sshd error metrics
If a client requests a ref that cannot be found in the repository, previously gitlab-sshd would record it as part of its service level indicator metric. This is really an application error between the client and the Git repository, so we exclude it from our metrics. Relates to https://gitlab.com/gitlab-com/gl-infra/reliability/-/issues/15848 Changelog: fixed
-rw-r--r--internal/sshd/connection.go7
-rw-r--r--internal/sshd/connection_test.go1
2 files changed, 7 insertions, 1 deletions
diff --git a/internal/sshd/connection.go b/internal/sshd/connection.go
index f471c69..7652bf1 100644
--- a/internal/sshd/connection.go
+++ b/internal/sshd/connection.go
@@ -21,7 +21,10 @@ import (
"gitlab.com/gitlab-org/labkit/log"
)
-const KeepAliveMsg = "keepalive@openssh.com"
+const (
+ KeepAliveMsg = "keepalive@openssh.com"
+ NotOurRefError = `exit status 128, stderr: "fatal: git upload-pack: not our ref `
+)
var EOFTimeout = 10 * time.Second
@@ -173,6 +176,8 @@ func (c *connection) trackError(ctxlog *logrus.Entry, err error) {
grpcCode := grpcstatus.Code(err)
if grpcCode == grpccodes.Canceled || grpcCode == grpccodes.Unavailable {
return
+ } else if grpcCode == grpccodes.Internal && strings.Contains(err.Error(), NotOurRefError) {
+ return
}
metrics.SliSshdSessionsErrorsTotal.Inc()
diff --git a/internal/sshd/connection_test.go b/internal/sshd/connection_test.go
index 9b440d2..4f54a1c 100644
--- a/internal/sshd/connection_test.go
+++ b/internal/sshd/connection_test.go
@@ -221,6 +221,7 @@ func TestSessionsMetrics(t *testing.T) {
{"unavailable Gitaly", grpcstatus.Error(grpccodes.Unavailable, "unavailable")},
{"api error", &client.ApiError{"api error"}},
{"disallowed command", disallowedcommand.Error},
+ {"not our ref", grpcstatus.Error(grpccodes.Internal, `rpc error: code = Internal desc = cmd wait: exit status 128, stderr: "fatal: git upload-pack: not our ref 9106d18f6a1b8022f6517f479696f3e3ea5e68c1"`)},
} {
t.Run(ignoredError.desc, func(t *testing.T) {
conn, chans = setup(1, newChannel)