diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /lib/gitlab/etag_caching | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'lib/gitlab/etag_caching')
-rw-r--r-- | lib/gitlab/etag_caching/middleware.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/etag_caching/router/graphql.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/etag_caching/router/rails.rb | 39 | ||||
-rw-r--r-- | lib/gitlab/etag_caching/store.rb | 4 |
4 files changed, 18 insertions, 33 deletions
diff --git a/lib/gitlab/etag_caching/middleware.rb b/lib/gitlab/etag_caching/middleware.rb index 786a68c86f2..5f06f37821c 100644 --- a/lib/gitlab/etag_caching/middleware.rb +++ b/lib/gitlab/etag_caching/middleware.rb @@ -57,7 +57,7 @@ module Gitlab end def weak_etag_format(value) - %{W/"#{value}"} + %(W/"#{value}") end def handle_cache_hit(etag, route, request) diff --git a/lib/gitlab/etag_caching/router/graphql.rb b/lib/gitlab/etag_caching/router/graphql.rb index 7946e768e00..50cdde88e2d 100644 --- a/lib/gitlab/etag_caching/router/graphql.rb +++ b/lib/gitlab/etag_caching/router/graphql.rb @@ -9,7 +9,7 @@ module Gitlab ROUTES = [ [ - %r(\Apipelines/id/\d+\z), + %r{\Apipelines/id/\d+\z}, 'pipelines_graph', 'continuous_integration' ], @@ -19,12 +19,12 @@ module Gitlab 'pipeline_composition' ], [ - %r(\Aon_demand_scan/counts/), + %r{\Aon_demand_scan/counts/}, 'on_demand_scans', 'dynamic_application_security_testing' ], [ - %r(\A/projects/.+/-/environments.json\z), + %r{\A/projects/.+/-/environments.json\z}, 'environment_details', 'continuous_delivery' ] diff --git a/lib/gitlab/etag_caching/router/rails.rb b/lib/gitlab/etag_caching/router/rails.rb index 5fd592c43e4..333bffd371f 100644 --- a/lib/gitlab/etag_caching/router/rails.rb +++ b/lib/gitlab/etag_caching/router/rails.rb @@ -10,9 +10,8 @@ module Gitlab # To match a regex the path needs to match the following: # - Don't contain a reserved word (expect for the words used in the # regex itself) - # - Ending in `noteable/issue/<id>/notes` for the `issue_notes` route # - Ending in `issues/id`/realtime_changes` for the `issue_title` route - USED_IN_ROUTES = %w[noteable issue notes issues realtime_changes + USED_IN_ROUTES = %w[noteable issue issues realtime_changes commit pipelines merge_requests builds new environments].freeze RESERVED_WORDS = Gitlab::PathRegex::ILLEGAL_PROJECT_PATH_WORDS - USED_IN_ROUTES @@ -21,85 +20,73 @@ module Gitlab ROUTES = [ [ - %r(#{RESERVED_WORDS_PREFIX}/noteable/issue/\d+/notes\z), - 'issue_notes', - ::Projects::NotesController, - :index - ], - [ - %r(#{RESERVED_WORDS_PREFIX}/noteable/merge_request/\d+/notes\z), - 'merge_request_notes', - ::Projects::NotesController, - :index - ], - [ - %r(#{RESERVED_WORDS_PREFIX}/issues/\d+/realtime_changes\z), + %r{#{RESERVED_WORDS_PREFIX}/issues/\d+/realtime_changes\z}, 'issue_title', ::Projects::IssuesController, :realtime_changes ], [ - %r(#{RESERVED_WORDS_PREFIX}/commit/\S+/pipelines\.json\z), + %r{#{RESERVED_WORDS_PREFIX}/commit/\S+/pipelines\.json\z}, 'commit_pipelines', ::Projects::CommitController, :pipelines ], [ - %r(#{RESERVED_WORDS_PREFIX}/merge_requests/new\.json\z), + %r{#{RESERVED_WORDS_PREFIX}/merge_requests/new\.json\z}, 'new_merge_request_pipelines', ::Projects::MergeRequests::CreationsController, :new ], [ - %r(#{RESERVED_WORDS_PREFIX}/merge_requests/\d+/pipelines\.json\z), + %r{#{RESERVED_WORDS_PREFIX}/merge_requests/\d+/pipelines\.json\z}, 'merge_request_pipelines', ::Projects::MergeRequestsController, :pipelines ], [ - %r(#{RESERVED_WORDS_PREFIX}/pipelines\.json\z), + %r{#{RESERVED_WORDS_PREFIX}/pipelines\.json\z}, 'project_pipelines', ::Projects::PipelinesController, :index ], [ - %r(#{RESERVED_WORDS_PREFIX}/pipelines/\d+\.json\z), + %r{#{RESERVED_WORDS_PREFIX}/pipelines/\d+\.json\z}, 'project_pipeline', ::Projects::PipelinesController, :show ], [ - %r(#{RESERVED_WORDS_PREFIX}/builds/\d+\.json\z), + %r{#{RESERVED_WORDS_PREFIX}/builds/\d+\.json\z}, 'project_build', ::Projects::BuildsController, :show ], [ - %r(#{RESERVED_WORDS_PREFIX}/clusters/\d+/environments\z), + %r{#{RESERVED_WORDS_PREFIX}/clusters/\d+/environments\z}, 'cluster_environments', ::Groups::ClustersController, :environments ], [ - %r(#{RESERVED_WORDS_PREFIX}/-/environments\.json\z), + %r{#{RESERVED_WORDS_PREFIX}/-/environments\.json\z}, 'environments', ::Projects::EnvironmentsController, :index ], [ - %r(#{RESERVED_WORDS_PREFIX}/import/github/realtime_changes\.json\z), + %r{#{RESERVED_WORDS_PREFIX}/import/github/realtime_changes\.json\z}, 'realtime_changes_import_github', ::Import::GithubController, :realtime_changes ], [ - %r(#{RESERVED_WORDS_PREFIX}/import/gitea/realtime_changes\.json\z), + %r{#{RESERVED_WORDS_PREFIX}/import/gitea/realtime_changes\.json\z}, 'realtime_changes_import_gitea', ::Import::GiteaController, :realtime_changes ], [ - %r(#{RESERVED_WORDS_PREFIX}/merge_requests/\d+/cached_widget\.json\z), + %r{#{RESERVED_WORDS_PREFIX}/merge_requests/\d+/cached_widget\.json\z}, 'merge_request_widget', ::Projects::MergeRequests::ContentController, :cached_widget diff --git a/lib/gitlab/etag_caching/store.rb b/lib/gitlab/etag_caching/store.rb index f36a7a0603c..5fdf5ac9436 100644 --- a/lib/gitlab/etag_caching/store.rb +++ b/lib/gitlab/etag_caching/store.rb @@ -31,9 +31,7 @@ module Gitlab private def with_redis(&blk) - # We use multistore as n interweaving double-write will result in n-1 subsequent requests - # becoming a cache-miss, however, 2 interweaving .touch will lead to 1 cache miss anyway. - Gitlab::Redis::EtagCache.with(&blk) # rubocop:disable CodeReuse/ActiveRecord + Gitlab::Redis::Cache.with(&blk) # rubocop:disable CodeReuse/ActiveRecord end def generate_etag |