New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes #19659 - capsule sync via bulk action #6861
Conversation
Issues: #19659 |
86648b0
to
bd53bf2
Compare
[test] |
[test] |
Getting this error after a sync but not sure if its related to your PR
|
@johnpmitsch i've seen that before, try restarting your dev env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, still testing out the functionality, just have some basic questions above around the code
end | ||
|
||
def humanized_input | ||
["'#{input['smart_proxy']['name']}'"] + super | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Showing the name of the proxy in the task 👍 💯
@@ -51,7 +51,7 @@ def remove_lifecycle_environment | |||
param :environment_id, Integer, :desc => N_('Id of the environment to limit the synchronization on') | |||
def sync | |||
find_environment if params[:environment_id] | |||
task = async_task(::Actions::Katello::CapsuleContent::Sync, capsule_content, :environment => @environment) | |||
task = async_task(::Actions::Katello::CapsuleContent::Sync, capsule_content.capsule, :environment_id => @environment.try(:id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change to environment_id? It seems like it's just used to find the environment below in app/lib/actions/katello/capsule_content/sync.rb (same question goes for the other ids too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With BulkAction, attempting to pass a hash containing AR resources resulted in plan phase errors similar to below; however, passing in a hash of IDs worked fine.
undefined method `to_hash' for #<Katello::ContentView:0x007f70248aa480>
I haven't found an alternative approach for passing in the resources, aside from passing in an array of arguments vs a hash. If you have suggestions, please do let me know. In most of Katello's usage of BulkAction, it does pass an array of arguments; however, I leaned away from it here, since we invoke the action differently depending upon scenario (e.g. cv + env vs repo).
repository_id = options.fetch(:repository_id, nil) | ||
repository = ::Katello::Repository.find(repository_id) unless repository_id.nil? | ||
content_view_id = options.fetch(:content_view_id, nil) | ||
content_view = ::Katello::ContentView.find(content_view_id) unless content_view_id.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more readable and I think would work the same
content_view = ::Katello::ContentView.find(content_view_id) if content_view_id
@@ -444,7 +444,8 @@ class CapsuleGenerateAndSyncTest < TestBase | |||
|
|||
it 'plans' do | |||
plan_action(action, repository) | |||
assert_action_planed_with(action, ::Actions::Katello::CapsuleContent::Sync, capsule_content, :repository => repository) | |||
assert_action_planned_with(action, ::Actions::BulkAction, ::Actions::Katello::CapsuleContent::Sync, | |||
[capsule_content.capsule], :repository_id => repository.id) | |||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How hard would it be to test two proxies syncing using bulk actions? That is some new functionality added by this PR and it would be nice to have the test coverage.
Moving the capsule sync to a bulk action. This will ensure that if one capsule is down, that the remaining syncs continue.
@johnpmitsch, Thanks for the feedback. I pushed several updates based upon the comments. I haven't found a good alternative yet to passing IDs vs resources for the BulkAction. We can revisit if folks have other suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well! If there isn't an existing issue to kick off a bulk sync manually from the UI, can we add that?
Thanks @johnpmitsch! Created http://projects.theforeman.org/issues/20323 for the ui enhancement. |
Moving the capsule sync to a bulk action.
This will ensure that if one capsule is down, that
the remaining syncs continue.