summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/command/shared/customaction/customaction.go3
-rw-r--r--internal/handler/exec.go18
-rw-r--r--internal/sshd/connection.go7
-rw-r--r--internal/sshd/sshd.go16
4 files changed, 23 insertions, 21 deletions
diff --git a/internal/command/shared/customaction/customaction.go b/internal/command/shared/customaction/customaction.go
index d91f8ab..34086fb 100644
--- a/internal/command/shared/customaction/customaction.go
+++ b/internal/command/shared/customaction/customaction.go
@@ -10,12 +10,13 @@ import (
"io"
"net/http"
- log "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet"
"gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/accessverifier"
"gitlab.com/gitlab-org/gitlab-shell/internal/pktline"
+
+ "gitlab.com/gitlab-org/labkit/log"
)
type Request struct {
diff --git a/internal/handler/exec.go b/internal/handler/exec.go
index fd0ea89..89856f7 100644
--- a/internal/handler/exec.go
+++ b/internal/handler/exec.go
@@ -8,19 +8,20 @@ import (
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
- log "github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
- gitalyauth "gitlab.com/gitlab-org/gitaly/v14/auth"
- "gitlab.com/gitlab-org/gitaly/v14/client"
- pb "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/accessverifier"
"gitlab.com/gitlab-org/gitlab-shell/internal/sshenv"
- "gitlab.com/gitlab-org/labkit/correlation"
+
+ gitalyauth "gitlab.com/gitlab-org/gitaly/v14/auth"
+ "gitlab.com/gitlab-org/gitaly/v14/client"
+ pb "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
grpccorrelation "gitlab.com/gitlab-org/labkit/correlation/grpc"
grpctracing "gitlab.com/gitlab-org/labkit/tracing/grpc"
+ "gitlab.com/gitlab-org/labkit/correlation"
+ "gitlab.com/gitlab-org/labkit/log"
)
// GitalyHandlerFunc implementations are responsible for making
@@ -75,7 +76,6 @@ func (gc *GitalyCommand) PrepareContext(ctx context.Context, repository *pb.Repo
func (gc *GitalyCommand) LogExecution(ctx context.Context, repository *pb.Repository, response *accessverifier.Response, env sshenv.Env) {
fields := log.Fields{
"command": gc.ServiceName,
- "correlation_id": correlation.ExtractFromContext(ctx),
"gl_project_path": repository.GlProjectPath,
"gl_repository": repository.GlRepository,
"user_id": response.UserId,
@@ -86,7 +86,7 @@ func (gc *GitalyCommand) LogExecution(ctx context.Context, repository *pb.Reposi
"gl_key_id": response.KeyId,
}
- log.WithFields(fields).Info("executing git command")
+ log.WithContextFields(ctx, fields).Info("executing git command")
}
func withOutgoingMetadata(ctx context.Context, features map[string]string) context.Context {
@@ -108,9 +108,9 @@ func getConn(ctx context.Context, gc *GitalyCommand) (*grpc.ClientConn, error) {
serviceName := correlation.ExtractClientNameFromContext(ctx)
if serviceName == "" {
- log.Warn("No gRPC service name specified, defaulting to gitlab-shell-unknown")
-
serviceName = "gitlab-shell-unknown"
+
+ log.WithFields(log.Fields{"service_name": serviceName}).Warn("No gRPC service name specified, defaulting to gitlab-shell-unknown")
}
serviceName = fmt.Sprintf("%s-%s", serviceName, gc.ServiceName)
diff --git a/internal/sshd/connection.go b/internal/sshd/connection.go
index 5ff055c..0e0da93 100644
--- a/internal/sshd/connection.go
+++ b/internal/sshd/connection.go
@@ -4,11 +4,12 @@ import (
"context"
"time"
- log "github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh"
"golang.org/x/sync/semaphore"
"gitlab.com/gitlab-org/gitlab-shell/internal/metrics"
+
+ "gitlab.com/gitlab-org/labkit/log"
)
type connection struct {
@@ -42,7 +43,7 @@ func (c *connection) handle(ctx context.Context, chans <-chan ssh.NewChannel, ha
}
channel, requests, err := newChannel.Accept()
if err != nil {
- log.Infof("Could not accept channel: %v", err)
+ log.WithError(err).Info("could not accept channel")
c.concurrentSessions.Release(1)
continue
}
@@ -53,7 +54,7 @@ func (c *connection) handle(ctx context.Context, chans <-chan ssh.NewChannel, ha
// Prevent a panic in a single session from taking out the whole server
defer func() {
if err := recover(); err != nil {
- log.Warnf("panic handling session from %s: recovered: %#+v", c.remoteAddr, err)
+ log.WithFields(log.Fields{"recovered_error": err}).Warnf("panic handling session from %s", c.remoteAddr)
}
}()
diff --git a/internal/sshd/sshd.go b/internal/sshd/sshd.go
index ac4ebf8..d3b5ec1 100644
--- a/internal/sshd/sshd.go
+++ b/internal/sshd/sshd.go
@@ -12,13 +12,13 @@ import (
"sync"
"net/http"
- log "github.com/sirupsen/logrus"
-
"github.com/pires/go-proxyproto"
"golang.org/x/crypto/ssh"
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/authorizedkeys"
+
+ "gitlab.com/gitlab-org/labkit/log"
"gitlab.com/gitlab-org/labkit/correlation"
)
@@ -89,7 +89,7 @@ func (s *Server) listen() error {
log.Info("Proxy protocol is enabled")
}
- log.Infof("Listening on %v", sshListener.Addr().String())
+ log.WithFields(log.Fields{"tcp_address": sshListener.Addr().String()}).Info("Listening for SSH connections")
s.listener = sshListener
@@ -111,7 +111,7 @@ func (s *Server) serve(ctx context.Context) error {
break
}
- log.Warnf("Failed to accept connection: %v\n", err)
+ log.WithError(err).Warn("Failed to accept connection")
continue
}
@@ -173,12 +173,12 @@ func (s *Server) initConfig(ctx context.Context) (*ssh.ServerConfig, error) {
for _, filename := range s.Config.Server.HostKeyFiles {
keyRaw, err := ioutil.ReadFile(filename)
if err != nil {
- log.Warnf("Failed to read host key %v: %v", filename, err)
+ log.WithError(err).Warnf("Failed to read host key %v", filename)
continue
}
key, err := ssh.ParsePrivateKey(keyRaw)
if err != nil {
- log.Warnf("Failed to parse host key %v: %v", filename, err)
+ log.WithError(err).Warnf("Failed to parse host key %v", filename)
continue
}
loadedHostKeys++
@@ -201,7 +201,7 @@ func (s *Server) handleConn(ctx context.Context, sshCfg *ssh.ServerConfig, nconn
// Prevent a panic in a single connection from taking out the whole server
defer func() {
if err := recover(); err != nil {
- log.Warnf("panic handling connection from %s: recovered: %#+v", remoteAddr, err)
+ log.WithFields(log.Fields{"recovered_error": err}).Warnf("panic handling session from %s", remoteAddr)
}
}()
@@ -210,7 +210,7 @@ func (s *Server) handleConn(ctx context.Context, sshCfg *ssh.ServerConfig, nconn
sconn, chans, reqs, err := ssh.NewServerConn(nconn, sshCfg)
if err != nil {
- log.Infof("Failed to initialize SSH connection: %v", err)
+ log.WithError(err).Info("Failed to initialize SSH connection")
return
}