Skip to content

Commit

Permalink
Fixes #36926 - RefreshRepos called for relevant repos only
Browse files Browse the repository at this point in the history
For unscoped Capsule Sync, call RefreshRepos only for repos to be
synced, not for all that exist on the Capsule.

Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
  • Loading branch information
pmoravec authored and sjha4 committed Nov 27, 2023
1 parent 7436bf1 commit 630215f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/lib/actions/katello/capsule_content/refresh_repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def plan(smart_proxy, options = {})
plan_self(:smart_proxy_id => smart_proxy.id,
:environment_id => options[:environment]&.id,
:content_view_id => options[:content_view]&.id,
:repository_id => options[:repository]&.id)
:repository_id => options[:repository]&.id,
:repository_ids_list => options[:repository_ids_list])
end

def invoke_external_task
Expand All @@ -33,7 +34,12 @@ def invoke_external_task
current_repos_on_capsule = smart_proxy_service.current_repositories(environment, content_view)
current_repos_on_capsule_ids = current_repos_on_capsule.pluck(:id)

list_of_repos_to_sync = smart_proxy_helper.combined_repos_available_to_capsule(environment, content_view, repository)
if input[:repository_ids_list].nil?
list_of_repos_to_sync = smart_proxy_helper.combined_repos_available_to_capsule(environment, content_view, repository)
else
list_of_repos_to_sync = ::Katello::Repository.where(:id => input[:repository_ids_list])
end

list_of_repos_to_sync.each do |repo|
next unless act_on_repo?(repo, smart_proxy)

Expand Down
1 change: 0 additions & 1 deletion app/lib/actions/katello/capsule_content/sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def plan(smart_proxy, options = {})
sequence do
if smart_proxy.has_feature?(SmartProxy::PULP3_FEATURE)
plan_action(Actions::Pulp3::ContentGuard::Refresh, smart_proxy)
plan_action(Actions::Pulp3::Orchestration::Repository::RefreshRepos, smart_proxy, refresh_options)
end
plan_action(SyncCapsule, smart_proxy, refresh_options)
end
Expand Down
7 changes: 7 additions & 0 deletions app/lib/actions/katello/capsule_content/sync_capsule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ def plan(smart_proxy, options = {})
repos = repos_to_sync(smart_proxy, environment, content_view, repository, skip_metadata_check)
return nil if repos.empty?

if environment.nil? && content_view.nil? && repository.nil?
options[:repository_ids_list] = repos.pluck(:id)
end
if smart_proxy.has_feature?(SmartProxy::PULP3_FEATURE)
plan_action(Actions::Pulp3::Orchestration::Repository::RefreshRepos, smart_proxy, options)
end

repos.in_groups_of(Setting[:foreman_proxy_content_batch_size], false) do |repo_batch|
concurrence do
repo_batch.each do |repo|
Expand Down
7 changes: 7 additions & 0 deletions test/actions/katello/capsule_content_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class SyncTest < TestBase
options = { smart_proxy_id: capsule_content.smart_proxy.id,
content_view_id: nil,
repository_id: repo.id,
repository_ids_list: nil,
environment_id: nil
}
assert_tree_planned_with(tree, ::Actions::Pulp3::Orchestration::Repository::RefreshRepos, options)
Expand Down Expand Up @@ -87,6 +88,7 @@ class SyncTest < TestBase
options = { smart_proxy_id: capsule_content.smart_proxy.id,
content_view_id: nil,
repository_id: repo.id,
repository_ids_list: nil,
environment_id: nil
}
assert_tree_planned_with(tree, ::Actions::Pulp3::Orchestration::Repository::RefreshRepos, options)
Expand Down Expand Up @@ -145,6 +147,7 @@ class SyncTest < TestBase
options = { smart_proxy_id: capsule_content.smart_proxy.id,
content_view_id: nil,
repository_id: repo.id,
repository_ids_list: nil,
environment_id: nil
}

Expand Down Expand Up @@ -174,6 +177,7 @@ class SyncTest < TestBase
options = { smart_proxy_id: capsule_content.smart_proxy.id,
content_view_id: nil,
repository_id: repo.id,
repository_ids_list: nil,
environment_id: nil
}

Expand All @@ -188,6 +192,7 @@ class SyncTest < TestBase
options = { smart_proxy_id: capsule_content.smart_proxy.id,
content_view_id: nil,
repository_id: repo.id,
repository_ids_list: nil,
environment_id: nil
}

Expand All @@ -202,6 +207,7 @@ class SyncTest < TestBase
options = { smart_proxy_id: capsule_content.smart_proxy.id,
content_view_id: nil,
repository_id: repo.id,
repository_ids_list: nil,
environment_id: nil
}

Expand All @@ -218,6 +224,7 @@ class SyncTest < TestBase
options = { smart_proxy_id: capsule_content.smart_proxy.id,
content_view_id: nil,
repository_id: nil,
repository_ids_list: nil,
environment_id: dev_environment.id
}
assert_tree_planned_with(tree, ::Actions::Pulp3::Orchestration::Repository::RefreshRepos, options)
Expand Down

0 comments on commit 630215f

Please sign in to comment.