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 #25440 - Remove hosts list from host bulk actions #7829

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -15,6 +15,7 @@ class Api::V2::HostsBulkActionsController < Api::V2::ApiController

# disable *_count fields on erratum rabl, since they perform N+1 queries
before_action :disable_erratum_hosts_count
before_action :set_compatibility_mode

resource_description do
api_version 'v2'
Expand Down Expand Up @@ -342,5 +343,9 @@ def find_content_view
def disable_erratum_hosts_count
@disable_counts = true
end

def set_compatibility_mode
@compatibility_mode = params[:compatibility_mode]
end
end
end
10 changes: 6 additions & 4 deletions app/views/katello/api/v2/hosts_bulk_actions/erratum.json.rabl
@@ -1,9 +1,11 @@
extends "katello/api/v2/errata/show"

node :applicable_hosts do |erratum|
erratum.hosts_available.where("#{::Host.table_name}.id" => @hosts).
select(["#{::Host.table_name}.id", "#{::Host.table_name}.name"]).
collect { |host| {:name => host.name, :id => host.id} }
if @compatibility_mode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about this for a bit. Since it effectively breaks the API I was going to request that you add the param to the apipie spec as well as rename it to make its function more clear.

Then I thought some more and concluded that this data seems out of place in the response of this API - after all, you are hiding this node by default. I guess it was trying to do too much by making a convenient API for the UI view rather than a performant and well-scoped API.

My vote would be to undo the compatibility mode change and add a deprecation warning to the two controller methods stating that the applicable hosts data will not be available from the API response in Katello 2.0

@jlsherrill does this sound like a sane suggestion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jturel I'm okay with that suggestion, however we may want to take over this pr as @ShimShtein i think is working on other stuff at the moment.

node :applicable_hosts do |erratum|
erratum.hosts_available.where("#{::Host.table_name}.id" => @hosts).
select(["#{::Host.table_name}.id", "#{::Host.table_name}.name"]).
collect { |host| {:name => host.name, :id => host.id} }
end
end

node(:affected_hosts_count) { |erratum| erratum.hosts_available(params[:organization_id]).where("#{::Host.table_name}.id" => @hosts).count }