Skip to content
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

Merged
merged 1 commit into from Jul 18, 2017

Conversation

bbuckingham
Copy link
Member

Moving the capsule sync to a bulk action.
This will ensure that if one capsule is down, that
the remaining syncs continue.

@theforeman-bot
Copy link

Issues: #19659

@bbuckingham bbuckingham changed the title fixes #19659 - capsule sync via bulk action WIP - fixes #19659 - capsule sync via bulk action Jul 10, 2017
@bbuckingham bbuckingham changed the title WIP - fixes #19659 - capsule sync via bulk action fixes #19659 - capsule sync via bulk action Jul 10, 2017
@bbuckingham
Copy link
Member Author

[test]

@jlsherrill
Copy link
Member

[test]

@johnpmitsch
Copy link
Contributor

Getting this error after a sync but not sure if its related to your PR

 | NameError: uninitialized constant ProxyAPI::PulpNode
 | /home/vagrant/katello/app/models/katello/concerns/smart_proxy_extensions.rb:73:in `update_puppet_path'
 | /home/vagrant/katello/app/models/katello/concerns/smart_proxy_extensions.rb:81:in `refresh_with_puppet_path'
 | /home/vagrant/foreman/app/controllers/api/v2/smart_proxies_controller.rb:60:in `refresh'

@jlsherrill
Copy link
Member

@johnpmitsch i've seen that before, try restarting your dev env

Copy link
Contributor

@johnpmitsch johnpmitsch left a 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
Copy link
Contributor

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))
Copy link
Contributor

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)

Copy link
Member Author

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?
Copy link
Contributor

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
Copy link
Contributor

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.

@johnpmitsch
Copy link
Contributor

When I shut down http on one proxy, the other one kept syncing, 👍 here

Moving the capsule sync to a bulk action.
This will ensure that if one capsule is down, that
the remaining syncs continue.
@bbuckingham
Copy link
Member Author

@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.

Copy link
Contributor

@johnpmitsch johnpmitsch left a 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?

@bbuckingham
Copy link
Member Author

Thanks @johnpmitsch! Created http://projects.theforeman.org/issues/20323 for the ui enhancement.

@bbuckingham bbuckingham merged commit a6452bf into Katello:master Jul 18, 2017
@bbuckingham bbuckingham deleted the 19659 branch July 18, 2017 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants