diff options
author | John Cai <jcai@gitlab.com> | 2021-12-16 21:38:14 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2021-12-16 21:38:14 +0300 |
commit | 61471fff6a262bc2c9c5270016f8a677e48638bb (patch) | |
tree | 2ce78c49318abb1916885bde6f883c5c66e64ce7 /cmd | |
parent | 1762b3a49fef1f12c2dc6ac153807b2c8c25b1fe (diff) | |
parent | 2766b879b037ad07e4313e76debbede691b40000 (diff) |
Merge branch 'pks-limithandler-remove-globals' into 'master'
limithandler: Refactor package to not use global state
See merge request gitlab-org/gitaly!4197
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gitaly-ssh/auth_test.go | 4 | ||||
-rw-r--r-- | cmd/gitaly/main.go | 7 |
2 files changed, 8 insertions, 3 deletions
diff --git a/cmd/gitaly-ssh/auth_test.go b/cmd/gitaly-ssh/auth_test.go index c12928611..3dd82bea1 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(cfg, 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..8b0e0da6e 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,10 @@ 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(cfg, limithandler.LimitConcurrencyByRepo) + prometheus.MustRegister(limitHandler) + + gitalyServerFactory := server.NewGitalyServerFactory(cfg, glog.Default(), registry, diskCache, limitHandler) defer gitalyServerFactory.Stop() ling, err := linguist.New(cfg) |