Skip to content

Commit b8a1bb4

Browse files
author
Igor Drozdov
committed
Merge branch 'sh-ignore-not-our-ref-errors' into 'main'
Ignore "not our ref" errors from gitlab-sshd error metrics See merge request gitlab-org/gitlab-shell!656
2 parents 5085fe7 + b5de479 commit b8a1bb4

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)