summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2021-05-14 16:47:16 +0100
committerNick Thomas <nick@gitlab.com>2021-05-17 15:52:55 +0100
commitde13980f3795679958a65881a813723da37894f5 (patch)
treed7968570d5ae972a737ceded3caf5d16dab484e7 /cmd
parentbc93a437b6cabb64360edfa698dacb4cc3ef02fe (diff)
downloadgitlab-shell-de13980f3795679958a65881a813723da37894f5.tar.gz
Fix opentracing setup for gitlab-sshd
Previously, opentracing (if configured) was initialized late in the gitlab-shell process's lifespan, coming just before making a gRPC call to Gitaly. By moving the opentracing initialization to be at process startup, we make it available for the whole process lifecycle, which is very useful to gitlab-sshd, as it means we'll only call tracing.Initialize() once on process startup, rather than once per SSH connection. To get this working, we need to introduce a context to gitlab-sshd. This carries the client/service name, but also carries an initial correlation ID. The main outcome of this is that all calls to the authorized_keys endpoint from a given gitlab-sshd process will now share a correlation ID. I don't have a strong opinion about this either way. Changelog: fixed
Diffstat (limited to 'cmd')
-rw-r--r--cmd/check/main.go2
-rw-r--r--cmd/gitlab-shell-authorized-keys-check/main.go2
-rw-r--r--cmd/gitlab-shell-authorized-principals-check/main.go2
-rw-r--r--cmd/gitlab-shell/main.go2
-rw-r--r--cmd/gitlab-sshd/main.go6
5 files changed, 9 insertions, 5 deletions
diff --git a/cmd/check/main.go b/cmd/check/main.go
index fbb520b..5a00781 100644
--- a/cmd/check/main.go
+++ b/cmd/check/main.go
@@ -39,7 +39,7 @@ func main() {
os.Exit(1)
}
- ctx, finished := command.ContextWithCorrelationID()
+ ctx, finished := command.Setup(executable.Name, config)
defer finished()
if err = cmd.Execute(ctx); err != nil {
diff --git a/cmd/gitlab-shell-authorized-keys-check/main.go b/cmd/gitlab-shell-authorized-keys-check/main.go
index 8746353..0fc7ecc 100644
--- a/cmd/gitlab-shell-authorized-keys-check/main.go
+++ b/cmd/gitlab-shell-authorized-keys-check/main.go
@@ -42,7 +42,7 @@ func main() {
os.Exit(1)
}
- ctx, finished := command.ContextWithCorrelationID()
+ ctx, finished := command.Setup(executable.Name, config)
defer finished()
if err = cmd.Execute(ctx); err != nil {
diff --git a/cmd/gitlab-shell-authorized-principals-check/main.go b/cmd/gitlab-shell-authorized-principals-check/main.go
index f14fbde..bdff1d3 100644
--- a/cmd/gitlab-shell-authorized-principals-check/main.go
+++ b/cmd/gitlab-shell-authorized-principals-check/main.go
@@ -42,7 +42,7 @@ func main() {
os.Exit(1)
}
- ctx, finished := command.ContextWithCorrelationID()
+ ctx, finished := command.Setup(executable.Name, config)
defer finished()
if err = cmd.Execute(ctx); err != nil {
diff --git a/cmd/gitlab-shell/main.go b/cmd/gitlab-shell/main.go
index 8286e66..16705eb 100644
--- a/cmd/gitlab-shell/main.go
+++ b/cmd/gitlab-shell/main.go
@@ -57,7 +57,7 @@ func main() {
os.Exit(1)
}
- ctx, finished := command.ContextWithCorrelationID()
+ ctx, finished := command.Setup(executable.Name, config)
defer finished()
if err = cmd.Execute(ctx); err != nil {
diff --git a/cmd/gitlab-sshd/main.go b/cmd/gitlab-sshd/main.go
index f777b9f..866bc8d 100644
--- a/cmd/gitlab-sshd/main.go
+++ b/cmd/gitlab-sshd/main.go
@@ -6,6 +6,7 @@ import (
log "github.com/sirupsen/logrus"
+ "gitlab.com/gitlab-org/gitlab-shell/internal/command"
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/internal/logger"
"gitlab.com/gitlab-org/gitlab-shell/internal/sshd"
@@ -59,6 +60,9 @@ func main() {
logger.ConfigureStandalone(cfg)
+ ctx, finished := command.Setup("gitlab-sshd", cfg)
+ defer finished()
+
// Startup monitoring endpoint.
if cfg.Server.WebListen != "" {
go func() {
@@ -71,7 +75,7 @@ func main() {
}()
}
- if err := sshd.Run(cfg); err != nil {
+ if err := sshd.Run(ctx, cfg); err != nil {
log.Fatalf("Failed to start GitLab built-in sshd: %v", err)
}
}