diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
commit | ee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch) | |
tree | f8479f94a28f66654c6a4f6fb99bad6b4e86a40e /lib/container_registry | |
parent | 62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff) |
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'lib/container_registry')
-rw-r--r-- | lib/container_registry/client.rb | 9 | ||||
-rw-r--r-- | lib/container_registry/gitlab_api_client.rb | 16 |
2 files changed, 21 insertions, 4 deletions
diff --git a/lib/container_registry/client.rb b/lib/container_registry/client.rb index 498bc11b168..723935f8aaf 100644 --- a/lib/container_registry/client.rb +++ b/lib/container_registry/client.rb @@ -10,6 +10,8 @@ module ContainerRegistry REGISTRY_FEATURES_HEADER = 'gitlab-container-registry-features' REGISTRY_TAG_DELETE_FEATURE = 'tag_delete' + DEFAULT_TAGS_PAGE_SIZE = 10000 + ALLOWED_REDIRECT_SCHEMES = %w[http https].freeze REDIRECT_OPTIONS = { clear_authorization_header: true, @@ -52,8 +54,11 @@ module ContainerRegistry } end - def repository_tags(name) - response_body faraday.get("/v2/#{name}/tags/list") + def repository_tags(name, page_size: DEFAULT_TAGS_PAGE_SIZE) + response = faraday.get("/v2/#{name}/tags/list") do |req| + req.params['n'] = page_size + end + response_body(response) end def repository_manifest(name, reference) diff --git a/lib/container_registry/gitlab_api_client.rb b/lib/container_registry/gitlab_api_client.rb index 2947dcb4b40..5dddd421223 100644 --- a/lib/container_registry/gitlab_api_client.rb +++ b/lib/container_registry/gitlab_api_client.rb @@ -23,6 +23,8 @@ module ContainerRegistry MAX_TAGS_PAGE_SIZE = 1000 + UnsuccessfulResponseError = Class.new(StandardError) + def self.supports_gitlab_api? with_dummy_client(return_value_if_disabled: false) do |client| client.supports_gitlab_api? @@ -105,12 +107,22 @@ module ContainerRegistry def tags(path, page_size: 100, last: nil) limited_page_size = [page_size, MAX_TAGS_PAGE_SIZE].min with_token_faraday do |faraday_client| - response = faraday_client.get("/gitlab/v1/repositories/#{path}/tags/list/") do |req| + url = "/gitlab/v1/repositories/#{path}/tags/list/" + response = faraday_client.get(url) do |req| req.params['n'] = limited_page_size req.params['last'] = last if last end - break {} unless response.success? + unless response.success? + Gitlab::ErrorTracking.log_exception( + UnsuccessfulResponseError.new, + class: self.class.name, + url: url, + status_code: response.status + ) + + break {} + end link_parser = Gitlab::Utils::LinkHeaderParser.new(response.headers['link']) |