Skip to content

Commit b5de479

Browse files
committed
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
1 parent 5085fe7 commit b5de479

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

internal/sshd/connection.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import (
2121
"gitlab.com/gitlab-org/labkit/log"
2222
)
2323

24-
const KeepAliveMsg = "[email protected]"
24+
const (
25+
KeepAliveMsg = "[email protected]"
26+
NotOurRefError = `exit status 128, stderr: "fatal: git upload-pack: not our ref `
27+
)
2528

2629
var EOFTimeout = 10 * time.Second
2730

@@ -173,6 +176,8 @@ func (c *connection) trackError(ctxlog *logrus.Entry, err error) {
173176
grpcCode := grpcstatus.Code(err)
174177
if grpcCode == grpccodes.Canceled || grpcCode == grpccodes.Unavailable {
175178
return
179+
} else if grpcCode == grpccodes.Internal && strings.Contains(err.Error(), NotOurRefError) {
180+
return
176181
}
177182

178183
metrics.SliSshdSessionsErrorsTotal.Inc()

internal/sshd/connection_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ func TestSessionsMetrics(t *testing.T) {
221221
{"unavailable Gitaly", grpcstatus.Error(grpccodes.Unavailable, "unavailable")},
222222
{"api error", &client.ApiError{"api error"}},
223223
{"disallowed command", disallowedcommand.Error},
224+
{"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"`)},
224225
} {
225226
t.Run(ignoredError.desc, func(t *testing.T) {
226227
conn, chans = setup(1, newChannel)

0 commit comments

Comments
 (0)