diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /lib/container_registry | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'lib/container_registry')
-rw-r--r-- | lib/container_registry/base_client.rb | 30 | ||||
-rw-r--r-- | lib/container_registry/client.rb | 6 | ||||
-rw-r--r-- | lib/container_registry/migration.rb | 14 |
3 files changed, 17 insertions, 33 deletions
diff --git a/lib/container_registry/base_client.rb b/lib/container_registry/base_client.rb index bb9422ae048..66bc934d1ef 100644 --- a/lib/container_registry/base_client.rb +++ b/lib/container_registry/base_client.rb @@ -31,9 +31,6 @@ module ContainerRegistry end }.freeze - # Taken from: FaradayMiddleware::FollowRedirects - REDIRECT_CODES = Set.new [301, 302, 303, 307] - class << self private @@ -98,23 +95,10 @@ module ContainerRegistry conn.adapter :net_http end - def response_body(response, allow_redirect: false) - if allow_redirect && REDIRECT_CODES.include?(response.status) - response = redirect_response(response.headers['location']) - end - + def response_body(response) response.body if response && response.success? end - def redirect_response(location) - return unless location - - uri = URI(@base_uri).merge(location) - raise ArgumentError, "Invalid scheme for #{location}" unless %w[http https].include?(uri.scheme) - - faraday_redirect.get(uri) - end - def configure_connection(conn) conn.headers['Accept'] = ACCEPTED_TYPES @@ -125,18 +109,6 @@ module ContainerRegistry conn.response :json, content_type: OCI_MANIFEST_V1_TYPE end - # Create a new request to make sure the Authorization header is not inserted - # via the Faraday middleware - def faraday_redirect - @faraday_redirect ||= faraday_base do |conn| - conn.request :json - - conn.request(:retry, RETRY_OPTIONS) - conn.request(:gitlab_error_callback, ERROR_CALLBACK_OPTIONS) - conn.adapter :net_http - end - end - def delete_if_exists(path) result = faraday.delete(path) diff --git a/lib/container_registry/client.rb b/lib/container_registry/client.rb index 4b2250d089d..498bc11b168 100644 --- a/lib/container_registry/client.rb +++ b/lib/container_registry/client.rb @@ -130,7 +130,7 @@ module ContainerRegistry def blob(name, digest, type = nil) type ||= 'application/octet-stream' - response_body faraday_blob.get("/v2/#{name}/blobs/#{digest}", nil, 'Accept' => type), allow_redirect: true + response_body faraday_blob.get("/v2/#{name}/blobs/#{digest}", nil, 'Accept' => type) end def delete_blob(name, digest) @@ -152,9 +152,7 @@ module ContainerRegistry @faraday_blob ||= faraday_base do |conn| initialize_connection(conn, @options) - if Feature.enabled?(:container_registry_follow_redirects_middleware, default_enabled: :yaml) - conn.use ::FaradayMiddleware::FollowRedirects, REDIRECT_OPTIONS - end + conn.use ::FaradayMiddleware::FollowRedirects, REDIRECT_OPTIONS end end end diff --git a/lib/container_registry/migration.rb b/lib/container_registry/migration.rb index 005ef880034..8377190c83c 100644 --- a/lib/container_registry/migration.rb +++ b/lib/container_registry/migration.rb @@ -20,6 +20,8 @@ module ContainerRegistry delegate :container_registry_import_max_step_duration, to: ::Gitlab::CurrentSettings delegate :container_registry_import_target_plan, to: ::Gitlab::CurrentSettings delegate :container_registry_import_created_before, to: ::Gitlab::CurrentSettings + delegate :container_registry_pre_import_timeout, to: ::Gitlab::CurrentSettings + delegate :container_registry_import_timeout, to: ::Gitlab::CurrentSettings alias_method :max_tags_count, :container_registry_import_max_tags_count alias_method :max_retries, :container_registry_import_max_retries @@ -27,6 +29,8 @@ module ContainerRegistry alias_method :max_step_duration, :container_registry_import_max_step_duration alias_method :target_plan_name, :container_registry_import_target_plan alias_method :created_before, :container_registry_import_created_before + alias_method :pre_import_timeout, :container_registry_pre_import_timeout + alias_method :import_timeout, :container_registry_import_timeout end def self.enabled? @@ -52,6 +56,8 @@ module ContainerRegistry # return 25 if Feature.enabled?(:container_registry_migration_phase2_capacity_25) return 10 if Feature.enabled?(:container_registry_migration_phase2_capacity_10) + return 5 if Feature.enabled?(:container_registry_migration_phase2_capacity_5) + return 2 if Feature.enabled?(:container_registry_migration_phase2_capacity_2) return 1 if Feature.enabled?(:container_registry_migration_phase2_capacity_1) 0 @@ -64,5 +70,13 @@ module ContainerRegistry def self.all_plans? Feature.enabled?(:container_registry_migration_phase2_all_plans) end + + def self.enqueue_twice? + Feature.enabled?(:container_registry_migration_phase2_enqueue_twice) + end + + def self.enqueuer_loop? + Feature.enabled?(:container_registry_migration_phase2_enqueuer_loop) + end end end |