forked from Katello/katello
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #36563 - Remove orphaned content unit cleanup from index_content (
Katello#10638) * Fixes #36563 - Move remove orphan content units to async task * Fixes #36563 - Run orphan content unit deletion during orphan cleanup only (cherry picked from commit 51f7a12)
- Loading branch information
Showing
12 changed files
with
55 additions
and
49 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
app/lib/actions/katello/orphan_cleanup/remove_orphaned_content_units.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Actions | ||
module Katello | ||
module OrphanCleanup | ||
class RemoveOrphanedContentUnits < Actions::Base | ||
def run | ||
models = [] | ||
|
||
::Katello::RepositoryTypeManager.enabled_repository_types.each_value do |repo_type| | ||
models << repo_type.content_types_to_index | ||
end | ||
models.flatten.each do |content_type| | ||
content_type.model_class.orphaned.destroy_all | ||
end | ||
end | ||
|
||
def rescue_strategy | ||
Dynflow::Action::Rescue::Skip | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
test/actions/katello/orphan_cleanup/remove_orphaned_content_units_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'katello_test_helper' | ||
module Katello | ||
class RemoveOrphanedContentUnitsTest < ActiveSupport::TestCase | ||
def setup | ||
@rhel6 = Repository.find(katello_repositories(:rhel_6_x86_64).id) | ||
end | ||
|
||
def test_orphaned_content_task_destroys_orphans | ||
rpm = katello_rpms(:one) | ||
rpm.repository_rpms.destroy_all | ||
ForemanTasks.sync_task(Actions::Katello::OrphanCleanup::RemoveOrphanedContentUnits) | ||
assert_raises(ActiveRecord::RecordNotFound) { rpm.reload } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters