As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit 33fdad1e authored by Archish's avatar Archish
Browse files

Lint fixes for logger metrics and pktline packages

parent cffe8fc0
No related branches found
No related tags found
No related merge requests found
// Package logger provides logging configuration utilities for the gitlab-shell
package logger package logger
import ( import (
Loading
@@ -52,7 +53,7 @@ func buildOpts(cfg *config.Config) []log.LoggerOption {
Loading
@@ -52,7 +53,7 @@ func buildOpts(cfg *config.Config) []log.LoggerOption {
// opened for writing. // opened for writing.
func Configure(cfg *config.Config) io.Closer { func Configure(cfg *config.Config) io.Closer {
var closer io.Closer = io.NopCloser(nil) var closer io.Closer = io.NopCloser(nil)
err := fmt.Errorf("No logfile specified") err := fmt.Errorf("no logfile specified")
if cfg.LogFile != "" { if cfg.LogFile != "" {
closer, err = log.Initialize(buildOpts(cfg)...) closer, err = log.Initialize(buildOpts(cfg)...)
Loading
@@ -66,7 +67,7 @@ func Configure(cfg *config.Config) io.Closer {
Loading
@@ -66,7 +67,7 @@ func Configure(cfg *config.Config) io.Closer {
syslogLogger.Print(msg) syslogLogger.Print(msg)
} else { } else {
msg := fmt.Sprintf("%s: Unable to configure logging: %v, %v\n", progName, err.Error(), syslogLoggerErr.Error()) msg := fmt.Sprintf("%s: Unable to configure logging: %v, %v\n", progName, err.Error(), syslogLoggerErr.Error())
fmt.Fprintf(os.Stderr, msg) fmt.Fprintln(os.Stderr, msg)
} }
cfg.LogFile = "/dev/null" cfg.LogFile = "/dev/null"
Loading
Loading
// Package metrics provides Prometheus metrics for monitoring gitlab-shell components.
package metrics package metrics
import ( import (
Loading
@@ -34,6 +35,7 @@ const (
Loading
@@ -34,6 +35,7 @@ const (
) )
var ( var (
// SshdSessionDuration is a histogram of latencies for connections to gitlab-shell sshd.
SshdSessionDuration = promauto.NewHistogram( SshdSessionDuration = promauto.NewHistogram(
prometheus.HistogramOpts{ prometheus.HistogramOpts{
Namespace: namespace, Namespace: namespace,
Loading
@@ -48,6 +50,7 @@ var (
Loading
@@ -48,6 +50,7 @@ var (
}, },
) )
// SshdSessionEstablishedDuration is a histogram of latencies until session established to gitlab-shell sshd.
SshdSessionEstablishedDuration = promauto.NewHistogram( SshdSessionEstablishedDuration = promauto.NewHistogram(
prometheus.HistogramOpts{ prometheus.HistogramOpts{
Namespace: namespace, Namespace: namespace,
Loading
@@ -62,6 +65,7 @@ var (
Loading
@@ -62,6 +65,7 @@ var (
}, },
) )
// SshdConnectionsInFlight is a gauge of connections currently being served by gitlab-shell sshd.
SshdConnectionsInFlight = promauto.NewGauge( SshdConnectionsInFlight = promauto.NewGauge(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Namespace: namespace, Namespace: namespace,
Loading
@@ -71,6 +75,7 @@ var (
Loading
@@ -71,6 +75,7 @@ var (
}, },
) )
// SshdHitMaxSessions is the number of times the concurrent sessions limit was hit in gitlab-shell sshd.
SshdHitMaxSessions = promauto.NewCounter( SshdHitMaxSessions = promauto.NewCounter(
prometheus.CounterOpts{ prometheus.CounterOpts{
Namespace: namespace, Namespace: namespace,
Loading
@@ -80,6 +85,7 @@ var (
Loading
@@ -80,6 +85,7 @@ var (
}, },
) )
// SliSshdSessionsTotal is the number of SSH sessions that have been established.
SliSshdSessionsTotal = promauto.NewCounter( SliSshdSessionsTotal = promauto.NewCounter(
prometheus.CounterOpts{ prometheus.CounterOpts{
Name: sliSshdSessionsTotalName, Name: sliSshdSessionsTotalName,
Loading
@@ -87,6 +93,7 @@ var (
Loading
@@ -87,6 +93,7 @@ var (
}, },
) )
// SliSshdSessionsErrorsTotal is the number of SSH sessions that have failed.
SliSshdSessionsErrorsTotal = promauto.NewCounter( SliSshdSessionsErrorsTotal = promauto.NewCounter(
prometheus.CounterOpts{ prometheus.CounterOpts{
Name: sliSshdSessionsErrorsTotalName, Name: sliSshdSessionsErrorsTotalName,
Loading
@@ -94,6 +101,7 @@ var (
Loading
@@ -94,6 +101,7 @@ var (
}, },
) )
// GitalyConnectionsTotal is a counter for the number of Gitaly connections that have been established,
GitalyConnectionsTotal = promauto.NewCounterVec( GitalyConnectionsTotal = promauto.NewCounterVec(
prometheus.CounterOpts{ prometheus.CounterOpts{
Namespace: namespace, Namespace: namespace,
Loading
@@ -147,6 +155,7 @@ var (
Loading
@@ -147,6 +155,7 @@ var (
}, },
) )
// LfsHTTPConnectionsTotal is the number of LFS over HTTP connections that have been established.
LfsHTTPConnectionsTotal = promauto.NewCounter( LfsHTTPConnectionsTotal = promauto.NewCounter(
prometheus.CounterOpts{ prometheus.CounterOpts{
Name: lfsHTTPConnectionsTotalName, Name: lfsHTTPConnectionsTotalName,
Loading
@@ -154,6 +163,7 @@ var (
Loading
@@ -154,6 +163,7 @@ var (
}, },
) )
// LfsSSHConnectionsTotal is the number of LFS over SSH connections that have been established.
LfsSSHConnectionsTotal = promauto.NewCounter( LfsSSHConnectionsTotal = promauto.NewCounter(
prometheus.CounterOpts{ prometheus.CounterOpts{
Name: lfsSSHConnectionsTotalName, Name: lfsSSHConnectionsTotalName,
Loading
@@ -162,6 +172,7 @@ var (
Loading
@@ -162,6 +172,7 @@ var (
) )
) )
// NewRoundTripper wraps an http.RoundTripper to instrument it with Prometheus metrics.
func NewRoundTripper(next http.RoundTripper) promhttp.RoundTripperFunc { func NewRoundTripper(next http.RoundTripper) promhttp.RoundTripperFunc {
rt := next rt := next
Loading
Loading
// Package pktline provides utility functions for working with the Git pkt-line format.
package pktline package pktline
// Utility functions for working with the Git pkt-line format. See // Utility functions for working with the Git pkt-line format. See
Loading
@@ -27,6 +28,7 @@ func NewScanner(r io.Reader) *bufio.Scanner {
Loading
@@ -27,6 +28,7 @@ func NewScanner(r io.Reader) *bufio.Scanner {
return scanner return scanner
} }
// IsRefRemoval checks if the packet represents a reference removal.
func IsRefRemoval(pkt []byte) bool { func IsRefRemoval(pkt []byte) bool {
return branchRemovalPktRegexp.Match(pkt) return branchRemovalPktRegexp.Match(pkt)
} }
Loading
Loading
Loading
@@ -329,14 +329,6 @@ internal/gitlabnet/lfstransfer/client.go:214:1: exported: exported method Client
Loading
@@ -329,14 +329,6 @@ internal/gitlabnet/lfstransfer/client.go:214:1: exported: exported method Client
internal/gitlabnet/lfstransfer/client.go:271:1: exported: exported method Client.Unlock should have comment or be unexported (revive) internal/gitlabnet/lfstransfer/client.go:271:1: exported: exported method Client.Unlock should have comment or be unexported (revive)
internal/gitlabnet/lfstransfer/client.go:321:1: exported: exported method Client.ListLocksVerify should have comment or be unexported (revive) internal/gitlabnet/lfstransfer/client.go:321:1: exported: exported method Client.ListLocksVerify should have comment or be unexported (revive)
internal/gitlabnet/personalaccesstoken/client_test.go:30:5: go-require: do not use require in http handlers (testifylint) internal/gitlabnet/personalaccesstoken/client_test.go:30:5: go-require: do not use require in http handlers (testifylint)
internal/logger/logger.go:1:1: package-comments: should have a package comment (revive)
internal/logger/logger.go:55:9: ST1005: error strings should not be capitalized (stylecheck)
internal/logger/logger.go:69:27: printf: non-constant format string in call to fmt.Fprintf (govet)
internal/metrics/metrics.go:1:1: package-comments: should have a package comment (revive)
internal/metrics/metrics.go:37:2: exported: exported var SshdSessionDuration should have comment or be unexported (revive)
internal/metrics/metrics.go:165:1: exported: exported function NewRoundTripper should have comment or be unexported (revive)
internal/pktline/pktline.go:1:1: package-comments: should have a package comment (revive)
internal/pktline/pktline.go:30:1: exported: exported function IsRefRemoval should have comment or be unexported (revive)
internal/sshd/gssapi_unsupported.go:11:1: exported: exported function NewGSSAPIServer should have comment or be unexported (revive) internal/sshd/gssapi_unsupported.go:11:1: exported: exported function NewGSSAPIServer should have comment or be unexported (revive)
internal/sshd/gssapi_unsupported.go:19:6: exported: exported type OSGSSAPIServer should have comment or be unexported (revive) internal/sshd/gssapi_unsupported.go:19:6: exported: exported type OSGSSAPIServer should have comment or be unexported (revive)
internal/sshd/gssapi_unsupported.go:23:1: exported: exported method OSGSSAPIServer.AcceptSecContext should have comment or be unexported (revive) internal/sshd/gssapi_unsupported.go:23:1: exported: exported method OSGSSAPIServer.AcceptSecContext should have comment or be unexported (revive)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment