Skip to content

Commit

Permalink
Fixes #29611 - Manifest delete refreshes library (#8677)
Browse files Browse the repository at this point in the history
This commit makes the ManifestDelete and Manifest Import refresh only
the rh library repositories. Prior to this commit even non library
repositories belonging to content views were checked for refresh.
  • Loading branch information
parthaa authored Apr 26, 2020
1 parent d0dad1e commit e801fb0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
3 changes: 2 additions & 1 deletion app/lib/actions/katello/organization/manifest_delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def plan(organization)
plan_action(Candlepin::Owner::DestroyImports, label: organization.label)

if SETTINGS[:katello][:use_pulp]
organization.products.redhat.flat_map(&:repositories).each do |repo|
repositories = ::Katello::Repository.in_default_view.in_product(::Katello::Product.redhat.in_org(organization))
repositories.each do |repo|
plan_action(Katello::Repository::RefreshRepository, repo)
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/lib/actions/katello/organization/manifest_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def plan(organization, path, force)
plan_action(Candlepin::Owner::ImportProducts, :organization_id => organization.id)

if manifest_update && SETTINGS[:katello][:use_pulp]
organization.products.redhat.flat_map(&:repositories).each do |repo|
repositories = ::Katello::Repository.in_default_view.in_product(::Katello::Product.redhat.in_org(organization))
repositories.each do |repo|
plan_action(Katello::Repository::RefreshRepository, repo)
end
end
Expand Down
32 changes: 13 additions & 19 deletions test/actions/katello/organization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ class ManifestRefreshTest < TestBase
it 'plans' do
acme_org = taxonomies(:empty_organization)
upstream = {}
rhel7 = katello_repositories(:rhel_7_x86_64)
acme_org.stubs(:owner_details).returns({})
acme_org.products.stubs(:redhat).returns([rhel7.product])
action.stubs(:action_subject).with(acme_org)
action.stubs(:rand).returns('1234')
plan_action(action, acme_org)
Expand Down Expand Up @@ -134,11 +132,11 @@ class ManifestRefreshTest < TestBase
organization_id: acme_org.id,
dependency: found.first.output
)
assert_action_planned_with(action,
::Actions::Katello::Repository::RefreshRepository,
rhel7,
dependency: found.first.output
)

assert_action_planned_with(action, ::Actions::Katello::Repository::RefreshRepository) do |repo, options|
assert repo.library_instance?
assert_equal options, dependency: found.first.output
end
end

it 'plans & create audit record for organization with comment manifest refreshed' do
Expand Down Expand Up @@ -218,8 +216,7 @@ class ManifestImportTest < TestBase
let(:action_class) { ::Actions::Katello::Organization::ManifestImport }

it 'plans' do
rhel7 = katello_repositories(:rhel_7_x86_64)
organization.products.stubs(:redhat).returns([rhel7.product])
organization = taxonomies(:empty_organization)
action.stubs(:action_subject).with(organization)
plan_action(action, organization, '/tmp/1234.zip', false)

Expand All @@ -233,10 +230,9 @@ class ManifestImportTest < TestBase
::Actions::Candlepin::Owner::ImportProducts,
organization_id: organization.id
)
assert_action_planned_with(action,
::Actions::Katello::Repository::RefreshRepository,
rhel7
)
assert_action_planned_with(action, ::Actions::Katello::Repository::RefreshRepository) do |args|
assert args.first.library_instance?
end
end

it 'plans & create audit record for organization with comment manifest imported' do
Expand Down Expand Up @@ -306,19 +302,17 @@ class ManifestDeleteTest < TestBase
let(:action_class) { ::Actions::Katello::Organization::ManifestDelete }

it 'plans' do
rhel7 = katello_repositories(:rhel_7_x86_64)
organization.products.stubs(:redhat).returns([rhel7.product])
organization = taxonomies(:empty_organization)
action.stubs(:action_subject).with(organization)
plan_action(action, organization)

assert_action_planned_with(action,
::Actions::Candlepin::Owner::DestroyImports,
label: organization.label
)
assert_action_planned_with(action,
::Actions::Katello::Repository::RefreshRepository,
rhel7
)
assert_action_planned_with(action, ::Actions::Katello::Repository::RefreshRepository) do |args|
assert args.first.library_instance?
end
end

it 'creates audit record for organization after manifest deletion' do
Expand Down

0 comments on commit e801fb0

Please sign in to comment.