Project

General

Profile

Bug #2497

Adding a USer fact filter causes an SQL error when provisioning a host

Added by Greg Sutcliffe about 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
High
Category:
Authorization
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Seen on Sat.Lab.TLV

Tried to provision a discovered host as non-admin user with a fact filter ( virtual == 'rhev' ). Got this stacktrace:

ActiveRecord::StatementInvalid
Mysql2::Error: Unknown column 'fact_values.host_id' in 'where clause': SELECT `hosts`.* FROM `hosts` WHERE (((hosts.owner_id in (NULL) AND hosts.owner_type = 'Usergroup') OR (hosts.owner_id = 64 AND hosts.owner_type = 'User')) or (hosts.domain_id in (6)) or (hosts.compute_resource_id in (16)) or ((hosts.id = fact_values.host_id and fact_values.fact_name_id = 438 and fact_values.value = 'rhev')) or (hosts.organization_id in (1,8)) or (hosts.location_id in (3,10)) )
app/models/host/managed.rb:520:in `enforce_permissions'
app/models/authorization.rb:12:in `enforce_edit_permissions'
lib/foreman/sti.rb:26:in `save'
app/models/taxonomy.rb:48:in `no_taxonomy_scope'
app/models/taxonomy.rb:55:in `as_taxonomy'
lib/foreman/thread_session.rb:140:in `as_location'
app/models/taxonomy.rb:54:in `as_taxonomy'
lib/foreman/thread_session.rb:105:in `as_org'
app/models/taxonomy.rb:53:in `as_taxonomy'
app/models/taxonomy.rb:47:in `no_taxonomy_scope'
lib/foreman/thread_session.rb:31:in `clear_thread'

Found in 346742902d8548e46877a214b2143dd79c3c4c69

Associated revisions

Revision 9ae88fc3 (diff)
Added by Greg Sutcliffe about 6 years ago

Fixes #2497 - Join to the fact_values table when a user fact-filter is applied

Revision 62be7fe7 (diff)
Added by Greg Sutcliffe about 6 years ago

Fixes #2497 - Join to the fact_values table when a user fact-filter is applied
(cherry picked from commit 9ae88fc3e7e4621df841eb6fb43fe938db4e52a5)

History

#1 Updated by Greg Sutcliffe about 6 years ago

  • Assignee set to Greg Sutcliffe

Replicated locally with a Managed Host - simply set Fact Filter "hostname" = "sapphire" and got:

SQLite3::SQLException: no such column: fact_values.host_id: SELECT "hosts".* FROM "hosts"  WHERE "hosts"."type" IN ('Host::Managed') AND ((hosts.compute_resource_id in (1))  or ((hosts.id = fact_values.host_id and fact_values.fact_name_id = 47 and fact_values.value = 'sapphire'))  or  (hosts.organization_id in (1,4))  or  (hosts.location_id in (2,3)) )

Investigating.

#2 Updated by Greg Sutcliffe about 6 years ago

  • Status changed from New to Ready For Testing
  • Priority changed from Normal to High

PR sent. Marking this as High as it causes Foreman to crash if you attempt to use the user fact filters at the moment.

#3 Updated by Greg Sutcliffe about 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF