Skip to content

Commit

Permalink
fixup! fixup! [PR] Fixes #38048 - Add rolling content views
Browse files Browse the repository at this point in the history
* add/fix Capsule-sync
  • Loading branch information
m-bucher committed Feb 24, 2025
1 parent 57245ce commit a31f4d0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/lib/actions/helpers/rolling_cv_repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def update_rolling_content_views(repo)

def update_rolling_content_views_async(repo)
concerned_repos(repo).each do |rolling_repo|
ForemanTasks.async_task(::Actions::Katello::ContentView::RefreshRollingRepo, rolling_repo)
ForemanTasks.sync_task(::Actions::Katello::ContentView::RefreshRollingRepo, rolling_repo)
end
end
end
Expand Down
11 changes: 11 additions & 0 deletions app/lib/actions/katello/content_view/add_rolling_repo_clone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module ContentView
class AddRollingRepoClone < Actions::EntryAction
def plan(content_view, repository_ids)
library = content_view.organization.library
clone_ids = []

concurrence do
::Katello::Repository.where(id: repository_ids).each do |repository|
Expand All @@ -18,9 +19,19 @@ def plan(content_view, repository_ids)
view_env_cp_id = content_view.content_view_environment(library).cp_id
content_id = repository.content_id
plan_action(Actions::Candlepin::Environment::AddContentToEnvironment, :view_env_cp_id => view_env_cp_id, :content_id => content_id)
clone_ids << clone.id
end
end
end
plan_self(repository_ids: clone_ids)
end

def run
if Setting[:foreman_proxy_content_auto_sync]
::Katello::Repository.where(id: input[:repository_ids]).each do |repo|
ForemanTasks.async_task(::Actions::Katello::Repository::CapsuleSync, repo)
end
end
end
end
end
Expand Down
7 changes: 3 additions & 4 deletions app/lib/actions/katello/repository/sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ def plan(repo, options = {})
end

def run
repo = ::Katello::Repository.find(input[:id])
repo.clear_smart_proxy_sync_histories if input[:contents_changed]
ForemanTasks.async_task(Repository::CapsuleSync, repo) if Setting[:foreman_proxy_content_auto_sync]
rescue ::Katello::Errors::CapsuleCannotBeReached # skip any capsules that cannot be connected to
end

def finalize
Expand All @@ -75,6 +71,9 @@ def finalize
repo&.audit_sync
update_rolling_content_views_async(repo)
end
repo.clear_smart_proxy_sync_histories if input[:contents_changed]
ForemanTasks.async_task(Repository::CapsuleSync, repo) if Setting[:foreman_proxy_content_auto_sync]
rescue ::Katello::Errors::CapsuleCannotBeReached # skip any capsules that cannot be connected to
end

def humanized_name
Expand Down
5 changes: 3 additions & 2 deletions test/actions/katello/content_view_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ class SyncRepositoryRefreshRollingRepoTest < TestBase
action.stubs(:input).returns(
id: clone_rpm.id
)
ForemanTasks.expects(:async_task).with(::Actions::Katello::ContentView::RefreshRollingRepo,
clone_rpm)
ForemanTasks.expects(:sync_task).with(::Actions::Katello::ContentView::RefreshRollingRepo,
clone_rpm)
ForemanTasks.expects(:async_task).with(::Actions::Katello::Repository::CapsuleSync, clone_rpm)
action.finalize
end
end
Expand Down

0 comments on commit a31f4d0

Please sign in to comment.