From c32d9acd6b8b681038720f897824f0ea5d43b644 Mon Sep 17 00:00:00 2001 From: Bernhard Suttner Date: Wed, 13 Nov 2024 14:51:30 +0100 Subject: [PATCH] Fixes #37929 - support download policies for file (#11184) * Fixes #37929 - support download policy for file * Cleanup unused method * fix file tests * Re-record VCRs --- .../katello/api/v2/repositories_controller.rb | 2 +- app/models/katello/root_repository.rb | 8 +- app/services/katello/pulp3/repository/file.rb | 6 +- .../details/views/repository-info.html | 6 +- .../new/new-repository.controller.js | 2 +- .../new/views/new-repository.html | 4 +- .../pulp3/orchestration/file_update_test.rb | 13 + .../models/katello_root_repositories.yml | 88 +- .../file_delete.yml | 174 +- .../yum_delete.yml | 166 +- .../actions/pulp3/file_create/create.yml | 232 +- ...delete_deleted_distribution_references.yml | 482 +- .../delete_deleted_remote_references.yml | 502 +- .../distribution_references_are_deleted.yml | 482 +- .../repository_reference_is_deleted.yml | 482 +- .../file_removeunits/empty_content_args.yml | 910 +- ...ontent_args_doesnt_update_version_href.yml | 922 +- ...ntent_units_doesnt_update_version_href.yml | 922 +- .../file_removeunits/remove_file_unit.yml | 900 +- .../remove_file_unit_updates_version_href.yml | 900 +- .../actions/pulp3/file_sync/sync.yml | 782 +- .../file_sync/sync_with_mirror_false.yml | 1600 +- .../pulp3/file_sync/sync_with_mirror_true.yml | 1506 +- .../pulp3/file_sync/sync_with_pagination.yml | 10927 +++--- .../pulp3/file_update/update_policy.yml | 1914 + .../file_update/update_set_unprotected.yml | 1128 +- .../file_update/update_ssl_validation.yml | 767 +- .../file_update/update_unset_unprotected.yml | 819 +- .../pulp3/file_upload/duplicate_upload.yml | 414 +- .../file_upload/duplicate_upload_binary.yml | 1206 +- .../duplicate_upload_binary_duplicate.yml | 874 +- .../actions/pulp3/file_upload/upload.yml | 384 +- .../pulp3/file_upload/upload_binary.yml | 1435 +- .../generate_metadata/generate_metadata.yml | 510 +- .../generate_with_sha1_root_repo_checksum.yml | 510 +- .../generate_with_source_repo.yml | 726 +- .../remove_orphans/orphans_are_removed.yml | 1605 +- .../pulp3/secure_repository_create/create.yml | 966 +- .../service/pulp3/content/chunk_upload.yml | 30569 +--------------- .../pulp3/content/chunk_upload_binary.yml | 5504 ++- .../service/pulp3/content/create_upload.yml | 30519 +-------------- .../service/pulp3/file_unit/index_model.yml | 642 +- .../service/pulp3/file_unit/index_on_sync.yml | 1286 +- .../repository_list/list_with_pagination.yml | 9236 +---- .../delete_orphan_repository_versions.yml | 1771 +- .../orphan_repository_versions.yml | 1573 +- .../needs_distributor_update.yml | 437 +- .../file/refresh_distribution/updates.yml | 630 +- 48 files changed, 30309 insertions(+), 87134 deletions(-) create mode 100644 test/fixtures/vcr_cassettes/actions/pulp3/file_update/update_policy.yml diff --git a/app/controllers/katello/api/v2/repositories_controller.rb b/app/controllers/katello/api/v2/repositories_controller.rb index ad1cc6da3e8..f7e2f2e6c08 100644 --- a/app/controllers/katello/api/v2/repositories_controller.rb +++ b/app/controllers/katello/api/v2/repositories_controller.rb @@ -52,7 +52,7 @@ def custom_index_relation(collection) param :docker_upstream_name, String, :desc => N_("Name of the upstream docker repository") param :include_tags, Array, :desc => N_("Comma-separated list of tags to sync for a container image repository") param :exclude_tags, Array, :desc => N_("Comma-separated list of tags to exclude when syncing a container image repository. Default: any tag ending in \"-source\"") - param :download_policy, ["immediate", "on_demand"], :desc => N_("download policy for yum, deb, and docker repos (either 'immediate' or 'on_demand')") + param :download_policy, ["immediate", "on_demand"], :desc => N_("download policy for deb, docker, file and yum repos (either 'immediate' or 'on_demand')") param :download_concurrency, :number, :desc => N_("Used to determine download concurrency of the repository in pulp3. Use value less than 20. Defaults to 10") param :mirroring_policy, Katello::RootRepository::MIRRORING_POLICIES, :desc => N_("Policy to set for mirroring content. Must be one of %s.") % RootRepository::MIRRORING_POLICIES param :verify_ssl_on_sync, :bool, :desc => N_("if true, Katello will verify the upstream url's SSL certifcates are signed by a trusted CA") diff --git a/app/models/katello/root_repository.rb b/app/models/katello/root_repository.rb index bebc763a9af..aaab69f8a5b 100644 --- a/app/models/katello/root_repository.rb +++ b/app/models/katello/root_repository.rb @@ -23,7 +23,7 @@ class RootRepository < Katello::Model SKIPABLE_METADATA_TYPES = [Repository::YUM_TYPE, Repository::DEB_TYPE].freeze CONTENT_ATTRIBUTE_RESTRICTIONS = { - :download_policy => [Repository::YUM_TYPE, Repository::DEB_TYPE, Repository::DOCKER_TYPE], + :download_policy => [Repository::YUM_TYPE, Repository::DEB_TYPE, Repository::DOCKER_TYPE, Repository::FILE_TYPE], }.freeze MAX_EXPIRE_TIME = 7 * 24 * 60 * 60 @@ -218,12 +218,6 @@ def self.hosts_with_applicability ::Host.joins(:content_facet => :bound_repositories).where("#{Katello::Repository.table_name}.root_id" => self.select(:id)) end - def ensure_no_download_policy - if !yum? && download_policy.present? - errors.add(:download_policy, _("cannot be set for non-yum repositories.")) - end - end - def ensure_no_checksum_on_demand if checksum_type.present? && download_policy == DOWNLOAD_ON_DEMAND errors.add(:checksum_type, _("Checksum type cannot be set for yum repositories with on demand download policy.")) diff --git a/app/services/katello/pulp3/repository/file.rb b/app/services/katello/pulp3/repository/file.rb index 1b7b2bbbc28..8e158f5aa6e 100644 --- a/app/services/katello/pulp3/repository/file.rb +++ b/app/services/katello/pulp3/repository/file.rb @@ -17,12 +17,14 @@ def distribution_options(path) end def remote_options + options = common_remote_options #TODO: move to user specifying PULP_MANIFEST if root.url.blank? - common_remote_options.merge(url: nil) + options[:url] = nil else - common_remote_options.merge(url: root.url + '/PULP_MANIFEST') + options[:url] = root.url + '/PULP_MANIFEST' end + options.merge!(policy: root.download_policy) end def partial_repo_path diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html index 939bbe71561..ef3c4d5f12c 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html @@ -54,7 +54,7 @@

Publishing Settings

Metadata Expiration (Seconds)
-
Sync Settings
- +
{{option.title}}
Sync Settings options="certs()" on-save="save(repository)">
- +
Download Policy
Sync Settings
Warning. Are you sure you want to add a comma in this whitespace separated list of distributions?
- +
@@ -296,7 +296,7 @@

Sync Settings

-
+