Skip to content

Commit 2fcac27

Browse files
Igor DrozdovArchish27
authored andcommitted
Merge branch '798-logger-lint' into 'main'
Lint fixes for logger metrics and pktline packages Closes #798 See merge request https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/1155 Merged-by: Igor Drozdov <[email protected]> Approved-by: James Fargher <[email protected]> Approved-by: Igor Drozdov <[email protected]> Reviewed-by: James Fargher <[email protected]> Co-authored-by: Archish <[email protected]>
2 parents 39ca1a6 + 33fdad1 commit 2fcac27

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

internal/logger/logger.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package logger provides logging configuration utilities for the gitlab-shell
12
package logger
23

34
import (
@@ -52,7 +53,7 @@ func buildOpts(cfg *config.Config) []log.LoggerOption {
5253
// opened for writing.
5354
func Configure(cfg *config.Config) io.Closer {
5455
var closer io.Closer = io.NopCloser(nil)
55-
err := fmt.Errorf("No logfile specified")
56+
err := fmt.Errorf("no logfile specified")
5657

5758
if cfg.LogFile != "" {
5859
closer, err = log.Initialize(buildOpts(cfg)...)
@@ -66,7 +67,7 @@ func Configure(cfg *config.Config) io.Closer {
6667
syslogLogger.Print(msg)
6768
} else {
6869
msg := fmt.Sprintf("%s: Unable to configure logging: %v, %v\n", progName, err.Error(), syslogLoggerErr.Error())
69-
fmt.Fprintf(os.Stderr, msg)
70+
fmt.Fprintln(os.Stderr, msg)
7071
}
7172

7273
cfg.LogFile = "/dev/null"

internal/metrics/metrics.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package metrics provides Prometheus metrics for monitoring gitlab-shell components.
12
package metrics
23

34
import (
@@ -34,6 +35,7 @@ const (
3435
)
3536

3637
var (
38+
// SshdSessionDuration is a histogram of latencies for connections to gitlab-shell sshd.
3739
SshdSessionDuration = promauto.NewHistogram(
3840
prometheus.HistogramOpts{
3941
Namespace: namespace,
@@ -48,6 +50,7 @@ var (
4850
},
4951
)
5052

53+
// SshdSessionEstablishedDuration is a histogram of latencies until session established to gitlab-shell sshd.
5154
SshdSessionEstablishedDuration = promauto.NewHistogram(
5255
prometheus.HistogramOpts{
5356
Namespace: namespace,
@@ -62,6 +65,7 @@ var (
6265
},
6366
)
6467

68+
// SshdConnectionsInFlight is a gauge of connections currently being served by gitlab-shell sshd.
6569
SshdConnectionsInFlight = promauto.NewGauge(
6670
prometheus.GaugeOpts{
6771
Namespace: namespace,
@@ -71,6 +75,7 @@ var (
7175
},
7276
)
7377

78+
// SshdHitMaxSessions is the number of times the concurrent sessions limit was hit in gitlab-shell sshd.
7479
SshdHitMaxSessions = promauto.NewCounter(
7580
prometheus.CounterOpts{
7681
Namespace: namespace,
@@ -80,20 +85,23 @@ var (
8085
},
8186
)
8287

88+
// SliSshdSessionsTotal is the number of SSH sessions that have been established.
8389
SliSshdSessionsTotal = promauto.NewCounter(
8490
prometheus.CounterOpts{
8591
Name: sliSshdSessionsTotalName,
8692
Help: "Number of SSH sessions that have been established",
8793
},
8894
)
8995

96+
// SliSshdSessionsErrorsTotal is the number of SSH sessions that have failed.
9097
SliSshdSessionsErrorsTotal = promauto.NewCounter(
9198
prometheus.CounterOpts{
9299
Name: sliSshdSessionsErrorsTotalName,
93100
Help: "Number of SSH sessions that have failed",
94101
},
95102
)
96103

104+
// GitalyConnectionsTotal is a counter for the number of Gitaly connections that have been established,
97105
GitalyConnectionsTotal = promauto.NewCounterVec(
98106
prometheus.CounterOpts{
99107
Namespace: namespace,
@@ -147,13 +155,15 @@ var (
147155
},
148156
)
149157

158+
// LfsHTTPConnectionsTotal is the number of LFS over HTTP connections that have been established.
150159
LfsHTTPConnectionsTotal = promauto.NewCounter(
151160
prometheus.CounterOpts{
152161
Name: lfsHTTPConnectionsTotalName,
153162
Help: "Number of LFS over HTTP connections that have been established",
154163
},
155164
)
156165

166+
// LfsSSHConnectionsTotal is the number of LFS over SSH connections that have been established.
157167
LfsSSHConnectionsTotal = promauto.NewCounter(
158168
prometheus.CounterOpts{
159169
Name: lfsSSHConnectionsTotalName,
@@ -162,6 +172,7 @@ var (
162172
)
163173
)
164174

175+
// NewRoundTripper wraps an http.RoundTripper to instrument it with Prometheus metrics.
165176
func NewRoundTripper(next http.RoundTripper) promhttp.RoundTripperFunc {
166177
rt := next
167178

internal/pktline/pktline.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package pktline provides utility functions for working with the Git pkt-line format.
12
package pktline
23

34
// Utility functions for working with the Git pkt-line format. See
@@ -27,6 +28,7 @@ func NewScanner(r io.Reader) *bufio.Scanner {
2728
return scanner
2829
}
2930

31+
// IsRefRemoval checks if the packet represents a reference removal.
3032
func IsRefRemoval(pkt []byte) bool {
3133
return branchRemovalPktRegexp.Match(pkt)
3234
}

support/lint_last_known_acceptable.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,6 @@ internal/gitlabnet/lfstransfer/client.go:214:1: exported: exported method Client
291291
internal/gitlabnet/lfstransfer/client.go:271:1: exported: exported method Client.Unlock should have comment or be unexported (revive)
292292
internal/gitlabnet/lfstransfer/client.go:321:1: exported: exported method Client.ListLocksVerify should have comment or be unexported (revive)
293293
internal/gitlabnet/personalaccesstoken/client_test.go:30:5: go-require: do not use require in http handlers (testifylint)
294-
internal/logger/logger.go:1:1: package-comments: should have a package comment (revive)
295-
internal/logger/logger.go:55:9: ST1005: error strings should not be capitalized (stylecheck)
296-
internal/logger/logger.go:69:27: printf: non-constant format string in call to fmt.Fprintf (govet)
297-
internal/metrics/metrics.go:1:1: package-comments: should have a package comment (revive)
298-
internal/metrics/metrics.go:37:2: exported: exported var SshdSessionDuration should have comment or be unexported (revive)
299-
internal/metrics/metrics.go:165:1: exported: exported function NewRoundTripper should have comment or be unexported (revive)
300-
internal/pktline/pktline.go:1:1: package-comments: should have a package comment (revive)
301-
internal/pktline/pktline.go:30:1: exported: exported function IsRefRemoval should have comment or be unexported (revive)
302294
internal/sshd/gssapi_unsupported.go:11:1: exported: exported function NewGSSAPIServer should have comment or be unexported (revive)
303295
internal/sshd/gssapi_unsupported.go:19:6: exported: exported type OSGSSAPIServer should have comment or be unexported (revive)
304296
internal/sshd/gssapi_unsupported.go:23:1: exported: exported method OSGSSAPIServer.AcceptSecContext should have comment or be unexported (revive)

0 commit comments

Comments
 (0)