Project

General

Profile

Bug #24702

Error while assigning location to a number of hosts that is larger than per_page setting

Added by Stephen Benjamin 3 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Category:
Organizations and Locations
Target version:
-

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1593553

Description of problem:

Version-Release number of selected component (if applicable):

How reproducible: Always

Steps to Reproduce:
1. Navigate to Hosts -> All Hosts
2. In the search box, use a filter like "lifecycle_environment = Library" that will yield a number of servers that is larger than the "Entries per page" setting.
3. select the check box that selects all hosts on this page and then select "Select all <no> hosts"
4. click on "Select Action" and select "Assign Location" from the drop-down box
5. select Fix Location on Mismatch and a location.
6. click Submit

Actual results:
Oops, we're sorry but something went wrong ERROR: missing FROM-clause entry for table "katello_environments" LINE 1: ..." WHERE "hosts"."type" IN ('Host::Managed') AND (("katello_e... ^

Expected results:
It should not show any error message

Additional info:
Similarly
Assign Organization produces a similar error when filter used "organization = <org-name>"
Oops, we're sorry but something went wrong ERROR: missing FROM-clause entry for table "taxonomies" LINE 1: ...Managed') AND "hosts"."organization_id" = 1 AND (("taxonomie... ^


Related issues

Related to Discovery - Bug #25095: Discovered host assign organization or assign location failureNew

Associated revisions

Revision 8a43c205 (diff)
Added by Stephen Benjamin 2 months ago

fixes #24702 - fix bulk taxonomy update w/ scoped search

If you go to the All Hosts page, and perform a search on a host
relation, like "model ~ Standard" and the results page is
more than per_page, and you select all results not just the first
page, it will fail with a SQL error: rails isn't correctly generated
the joins for the relation. This is fixed in Rails 5.2.x.

History

#1 Updated by Stephen Benjamin 3 months ago

  • Subject changed from Error while assigning location to a number of hosts that is larger than per_page setting to Error while assigning location to a number of hosts that is larger than per_page setting

This is happening because of a bug that's fixed in Rails 5.2:

https://github.com/rails/rails/issues/28863

#2 Updated by The Foreman Bot 3 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5982 added

#3 Updated by The Foreman Bot 3 months ago

  • Pull request https://github.com/theforeman/foreman/pull/6017 added

#4 Updated by The Foreman Bot 3 months ago

  • Pull request https://github.com/theforeman/foreman/pull/6018 added

#5 Updated by Ondřej Pražák 3 months ago

  • Fixed in Releases 1.18.2 added

#6 Updated by Ondřej Pražák 3 months ago

  • Status changed from Ready For Testing to Closed

#7 Updated by Tomer Brisker 2 months ago

  • Fixed in Releases 1.19.1, 1.20.0 added

#8 Updated by Lukas Zapletal about 2 months ago

Guys, I assume this patch is 1.18 and 1.19 only. It caused regression in discovery (#25095) and I am not sure how to fix this yet. My assumption is to change this to something like:

@hosts = @hosts.klass.where('hosts.id IN (?)', @hosts.pluck(:id))

But the error stays at PG::AmbiguousColumn: ERROR: column reference "id" is ambiguous LINE 1: ...WHERE "hosts"."type" IN ('Host::Discovered') AND (id IN ('1'... ^ : SELECT "hosts"."id" FROM "hosts" LEFT OUTER JOIN "models" ON "models"."id" = "hosts"."model_id" LEFT OUTER JOIN "fact_values" ON "fact_values"."host_id" = "hosts"."id" LEFT OUTER JOIN "nics" ON "nics"."host_id" = "hosts"."id" LEFT OUTER JOIN "taxonomies" ON "taxonomies"."id" = "hosts"."location_id" AND "taxonomies"."type" IN ('Location') LEFT OUTER JOIN "taxonomies" "organizations_hosts" ON "organizations_hosts"."id" = "hosts"."organization_id" AND "organizations_hosts"."type" IN ('Organization') WHERE "hosts"."type" IN ('Host::Discovered') AND (id IN ('1') or name IN (NULL)) ORDER BY hosts.created_at DESC

#9 Updated by Lukas Zapletal about 2 months ago

  • Related to Bug #25095: Discovered host assign organization or assign location failure added

#10 Updated by Tomer Brisker about 1 month ago

  • Category set to Organizations and Locations

Also available in: Atom PDF