app/lib/actions/katello/capsule_content/sync.rb in katello-3.4.5 vs app/lib/actions/katello/capsule_content/sync.rb in katello-3.5.0.rc1

- old
+ new

@@ -28,10 +28,11 @@ environment = ::Katello::KTEnvironment.find(environment_id) if environment_id repository_id = options.fetch(:repository_id, nil) repository = ::Katello::Repository.find(repository_id) if repository_id content_view_id = options.fetch(:content_view_id, nil) content_view = ::Katello::ContentView.find(content_view_id) if content_view_id + skip_metadata_check = options.fetch(:skip_metadata_check, false) fail _("Action not allowed for the default capsule.") if capsule_content.default_capsule? affected_repos = affected_repositories(capsule_content, environment, content_view, repository) need_updates = repos_needing_updates(capsule_content, affected_repos) @@ -40,16 +41,16 @@ sequence do need_updates.each do |repo| plan_action(Pulp::Repository::Refresh, repo, capsule_id: capsule_content.capsule.id) end plan_action(ConfigureCapsule, capsule_content, environment, content_view, repository) - sync_repos_to_capsule(capsule_content, repository_ids) + sync_repos_to_capsule(capsule_content, repository_ids, skip_metadata_check) end end end - def sync_repos_to_capsule(capsule_content, repository_ids) + def sync_repos_to_capsule(capsule_content, repository_ids, skip_metadata_check) concurrence do repository_ids.each do |repo_id| sequence do repo = ::Katello::Repository.find_by(pulp_id: repo_id) || ::Katello::ContentViewPuppetEnvironment.find_by(pulp_id: repo_id) @@ -58,13 +59,21 @@ # during publish. (i.e. two versions of a unit in the same repo) plan_action(Pulp::Consumer::UnassociateUnits, capsule_id: capsule_content.capsule.id, repo_pulp_id: repo_id) end + pulp_options = { remove_missing: repo && ["puppet", "yum"].include?(repo.content_type) } + pulp_options[:force_full] = true if skip_metadata_check && repo.content_type == "yum" plan_action(Pulp::Consumer::SyncCapsule, capsule_id: capsule_content.capsule.id, repo_pulp_id: repo_id, - sync_options: { remove_missing: repo && ["puppet", "yum"].include?(repo.content_type) }) + sync_options: pulp_options) + if skip_metadata_check + plan_action(Katello::Repository::MetadataGenerate, + repo, + capsule_id: capsule_content.capsule.id, + force: true) + end end end end end