diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-31 09:12:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-31 09:12:36 +0300 |
commit | 136651d7cb69357d2823adefac430df389e81e17 (patch) | |
tree | 9e501e488170ff6f8be0f7fec2405a54440391d4 /workhorse/internal/upstream | |
parent | a5bd90f43bbd7d7b3222cf84698daa2cbc6e2b3f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'workhorse/internal/upstream')
-rw-r--r-- | workhorse/internal/upstream/metrics_test.go | 2 | ||||
-rw-r--r-- | workhorse/internal/upstream/routes.go | 3 | ||||
-rw-r--r-- | workhorse/internal/upstream/upstream.go | 9 | ||||
-rw-r--r-- | workhorse/internal/upstream/upstream_test.go | 4 |
4 files changed, 10 insertions, 8 deletions
diff --git a/workhorse/internal/upstream/metrics_test.go b/workhorse/internal/upstream/metrics_test.go index 29a9e09777c..dff849ac214 100644 --- a/workhorse/internal/upstream/metrics_test.go +++ b/workhorse/internal/upstream/metrics_test.go @@ -26,7 +26,7 @@ func TestInstrumentGeoProxyRoute(t *testing.T) { handleRouteWithMatchers(u, local), handleRouteWithMatchers(u, main), } - }) + }, nil) ts := httptest.NewServer(u) defer ts.Close() diff --git a/workhorse/internal/upstream/routes.go b/workhorse/internal/upstream/routes.go index 899e5d9835e..288871d558d 100644 --- a/workhorse/internal/upstream/routes.go +++ b/workhorse/internal/upstream/routes.go @@ -21,7 +21,6 @@ import ( "gitlab.com/gitlab-org/gitlab/workhorse/internal/imageresizer" proxypkg "gitlab.com/gitlab-org/gitlab/workhorse/internal/proxy" "gitlab.com/gitlab-org/gitlab/workhorse/internal/queueing" - "gitlab.com/gitlab-org/gitlab/workhorse/internal/redis" "gitlab.com/gitlab-org/gitlab/workhorse/internal/secret" "gitlab.com/gitlab-org/gitlab/workhorse/internal/senddata" "gitlab.com/gitlab-org/gitlab/workhorse/internal/sendfile" @@ -223,7 +222,7 @@ func configureRoutes(u *upstream) { tempfileMultipartProxy := upload.FixedPreAuthMultipart(api, proxy, preparer) ciAPIProxyQueue := queueing.QueueRequests("ci_api_job_requests", tempfileMultipartProxy, u.APILimit, u.APIQueueLimit, u.APIQueueTimeout) - ciAPILongPolling := builds.RegisterHandler(ciAPIProxyQueue, redis.WatchKey, u.APICILongPollingDuration) + ciAPILongPolling := builds.RegisterHandler(ciAPIProxyQueue, u.watchKeyHandler, u.APICILongPollingDuration) dependencyProxyInjector.SetUploadHandler(requestBodyUploader) diff --git a/workhorse/internal/upstream/upstream.go b/workhorse/internal/upstream/upstream.go index 43b470b568f..248f190e316 100644 --- a/workhorse/internal/upstream/upstream.go +++ b/workhorse/internal/upstream/upstream.go @@ -21,6 +21,7 @@ import ( "gitlab.com/gitlab-org/labkit/correlation" apipkg "gitlab.com/gitlab-org/gitlab/workhorse/internal/api" + "gitlab.com/gitlab-org/gitlab/workhorse/internal/builds" "gitlab.com/gitlab-org/gitlab/workhorse/internal/config" "gitlab.com/gitlab-org/gitlab/workhorse/internal/helper" proxypkg "gitlab.com/gitlab-org/gitlab/workhorse/internal/proxy" @@ -55,19 +56,21 @@ type upstream struct { accessLogger *logrus.Logger enableGeoProxyFeature bool mu sync.RWMutex + watchKeyHandler builds.WatchKeyHandler } -func NewUpstream(cfg config.Config, accessLogger *logrus.Logger) http.Handler { - return newUpstream(cfg, accessLogger, configureRoutes) +func NewUpstream(cfg config.Config, accessLogger *logrus.Logger, watchKeyHandler builds.WatchKeyHandler) http.Handler { + return newUpstream(cfg, accessLogger, configureRoutes, watchKeyHandler) } -func newUpstream(cfg config.Config, accessLogger *logrus.Logger, routesCallback func(*upstream)) http.Handler { +func newUpstream(cfg config.Config, accessLogger *logrus.Logger, routesCallback func(*upstream), watchKeyHandler builds.WatchKeyHandler) http.Handler { up := upstream{ Config: cfg, accessLogger: accessLogger, // Kind of a feature flag. See https://gitlab.com/groups/gitlab-org/-/epics/5914#note_564974130 enableGeoProxyFeature: os.Getenv("GEO_SECONDARY_PROXY") != "0", geoProxyBackend: &url.URL{}, + watchKeyHandler: watchKeyHandler, } if up.geoProxyPollSleep == nil { up.geoProxyPollSleep = time.Sleep diff --git a/workhorse/internal/upstream/upstream_test.go b/workhorse/internal/upstream/upstream_test.go index 21fa7b81fdb..7ab3e67116f 100644 --- a/workhorse/internal/upstream/upstream_test.go +++ b/workhorse/internal/upstream/upstream_test.go @@ -58,7 +58,7 @@ func TestRouting(t *testing.T) { handle(u, quxbaz), handle(u, main), } - }) + }, nil) ts := httptest.NewServer(u) defer ts.Close() @@ -415,7 +415,7 @@ func startWorkhorseServer(railsServerURL string, enableGeoProxyFeature bool) (*h configureRoutes(u) } cfg := newUpstreamConfig(railsServerURL) - upstreamHandler := newUpstream(*cfg, logrus.StandardLogger(), myConfigureRoutes) + upstreamHandler := newUpstream(*cfg, logrus.StandardLogger(), myConfigureRoutes, nil) ws := httptest.NewServer(upstreamHandler) waitForNextApiPoll := func() {} |