Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-14 15:53:59 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-15 10:15:39 +0300
commitbbc8ddda6b33ee1afa88b328a5cf53ce7f5d64f0 (patch)
tree2cf26b5b863cd4404c1e7986d4cfd8ca62cbac65 /cmd
parent16c002aa3c141b0a7e0ece4584c3b3872e48ce0d (diff)
gitaly: Inject the limit handler
The limit handler is currently created ad-hoc by Gitaly's server code. We're about to change the way it hosts Prometheus metrics though such that we can get rid of a set of global variables, and this will require us to make sure that there's only a single instance of the limiter. Inject the limit handler as a dependency when creating the server to prepare for this.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gitaly-ssh/auth_test.go4
-rw-r--r--cmd/gitaly/main.go6
2 files changed, 7 insertions, 3 deletions
diff --git a/cmd/gitaly-ssh/auth_test.go b/cmd/gitaly-ssh/auth_test.go
index c12928611..c15901765 100644
--- a/cmd/gitaly-ssh/auth_test.go
+++ b/cmd/gitaly-ssh/auth_test.go
@@ -22,6 +22,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service/setup"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitlab"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/middleware/limithandler"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
@@ -154,8 +155,9 @@ func runServer(t *testing.T, secure bool, cfg config.Cfg, connectionType string,
t, gitlab.MockAllowed, gitlab.MockPreReceive, gitlab.MockPostReceive,
), cfg)
gitCmdFactory := git.NewExecCommandFactory(cfg)
+ limitHandler := limithandler.New(limithandler.LimitConcurrencyByRepo)
diskCache := cache.New(cfg, locator)
- srv, err := server.New(secure, cfg, testhelper.NewDiscardingLogEntry(t), registry, diskCache)
+ srv, err := server.New(secure, cfg, testhelper.NewDiscardingLogEntry(t), registry, diskCache, limitHandler)
require.NoError(t, err)
setup.RegisterAll(srv, &service.Dependencies{
Cfg: cfg,
diff --git a/cmd/gitaly/main.go b/cmd/gitaly/main.go
index 1571c1d73..2699fa5de 100644
--- a/cmd/gitaly/main.go
+++ b/cmd/gitaly/main.go
@@ -31,6 +31,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitlab"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
glog "gitlab.com/gitlab-org/gitaly/v14/internal/log"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/middleware/limithandler"
"gitlab.com/gitlab-org/gitaly/v14/internal/streamcache"
"gitlab.com/gitlab-org/gitaly/v14/internal/tempdir"
"gitlab.com/gitlab-org/gitaly/v14/internal/version"
@@ -108,7 +109,6 @@ func configure(configPath string) (config.Cfg, error) {
sentry.ConfigureSentry(version.GetVersion(), sentry.Config(cfg.Logging.Sentry))
cfg.Prometheus.Configure()
- config.ConfigureConcurrencyLimits(cfg)
tracing.Initialize(tracing.WithServiceName("gitaly"))
preloadLicenseDatabase()
@@ -192,7 +192,9 @@ func run(cfg config.Cfg) error {
return fmt.Errorf("disk cache walkers: %w", err)
}
- gitalyServerFactory := server.NewGitalyServerFactory(cfg, glog.Default(), registry, diskCache)
+ limitHandler := limithandler.New(limithandler.LimitConcurrencyByRepo)
+
+ gitalyServerFactory := server.NewGitalyServerFactory(cfg, glog.Default(), registry, diskCache, limitHandler)
defer gitalyServerFactory.Stop()
ling, err := linguist.New(cfg)