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/workhorse.rb | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'lib/gitlab/workhorse.rb')
-rw-r--r-- | lib/gitlab/workhorse.rb | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb index 79131404465..d19dd6cd856 100644 --- a/lib/gitlab/workhorse.rb +++ b/lib/gitlab/workhorse.rb @@ -15,7 +15,7 @@ module Gitlab NOTIFICATION_PREFIX = 'workhorse:notifications:' ALLOWED_GIT_HTTP_ACTIONS = %w[git_receive_pack git_upload_pack info_refs].freeze DETECT_HEADER = 'Gitlab-Workhorse-Detect-Content-Type' - ARCHIVE_FORMATS = %w(zip tar.gz tar.bz2 tar).freeze + ARCHIVE_FORMATS = %w[zip tar.gz tar.bz2 tar].freeze include JwtAuthenticatable @@ -184,11 +184,17 @@ module Gitlab ] end - def send_dependency(headers, url) + def send_dependency(headers, url, upload_config: {}) params = { - 'Header' => headers, - 'Url' => url + 'Headers' => headers.transform_values { |v| Array.wrap(v) }, + 'Url' => url, + 'UploadConfig' => { + 'Method' => upload_config[:method], + 'Url' => upload_config[:url], + 'Headers' => (upload_config[:headers] || {}).transform_values { |v| Array.wrap(v) } + }.compact_blank! } + params.compact_blank! [ SEND_DATA_HEADER, @@ -227,8 +233,12 @@ module Gitlab Gitlab.config.workhorse.secret_file end + def cleanup_key(key) + with_redis { |redis| redis.del(key) } + end + def set_key_and_notify(key, value, expire: nil, overwrite: true) - Gitlab::Redis::SharedState.with do |redis| + with_redis do |redis| result = redis.set(key, value, ex: expire, nx: !overwrite) if result redis.publish(NOTIFICATION_PREFIX + key, value) @@ -249,6 +259,15 @@ module Gitlab protected + def with_redis(&blk) + if Feature.enabled?(:use_primary_and_secondary_stores_for_workhorse) || + Feature.enabled?(:use_primary_store_as_default_for_workhorse) + Gitlab::Redis::Workhorse.with(&blk) # rubocop:disable CodeReuse/ActiveRecord + else + Gitlab::Redis::SharedState.with(&blk) # rubocop:disable CodeReuse/ActiveRecord + end + end + # This is the outermost encoding of a senddata: header. It is safe for # inclusion in HTTP response headers def encode(hash) |