Project

General

Profile

Bug #5106

Non-Puppet proxies are shown in new host form Puppet proxy dropdowns

Added by Dominic Cleal about 5 years ago. Updated 12 months ago.

Status:
Closed
Priority:
Normal
Category:
Host creation
Target version:
Difficulty:
Triaged:
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

When creating a new host, smart proxies without the Puppet or Puppet CA features are listed in the "Puppet Master" and "Puppet CA" dropdown menus.

This seems to be an issue with the use of the "with_taxonomy_scope_override" scope as it forces an unscoped list of smart proxies, which means we lose the filtered view of proxies with particular features:

app/helpers/hosts_and_hostgroups_helper.rb
52:    proxies = SmartProxy.with_features("Puppet CA").with_taxonomy_scope_override(@location,@organization)

SmartProxy.with_features("Puppet CA") returns the Puppet CA proxies, but then calling .with_taxonomy_scope_override on that calls unscoped so it becomes a list of all proxies, filtered by location + org.

Marking for 1.5.0 as it's a regression.


Related issues

Related to Foreman - Bug #5660: All OS Mirrors are Shown in the Dropdown listClosed2014-05-10

Associated revisions

Revision 50e0bc5c (diff)
Added by Dmitri Dolguikh about 5 years ago

fixes #5106: only puppet and puppet-ca proxies are now being shown on the 'new host' page

Revision 2afa8abd (diff)
Added by Dmitri Dolguikh about 5 years ago

fixes #5106: only puppet and puppet-ca proxies are now being shown on the 'new host' page

(cherry picked from commit 50e0bc5cea3a3406ffe94988d43a5915b1cd0717)

History

#1 Updated by Stephen Benjamin about 5 years ago

This also happens with OS Media in hosts_and_hostgroups_helper.rb:

@operatingsystem.media.with_taxonomy_scope_override(@location,@organization)

#2 Updated by Lukas Zapletal about 5 years ago

It looks like changing order of the clauses does help, but it does not look like a proper fix:

[12] pry(main)> SmartProxy.with_features("Puppet CA").with_taxonomy_scope_override(Location.first, Organization.first)
  Location Load (0.2ms)  SELECT "taxonomies".* FROM "taxonomies" WHERE "taxonomies"."type" IN ('Location') ORDER BY title LIMIT 1
  Organization Load (0.1ms)  SELECT "taxonomies".* FROM "taxonomies" WHERE "taxonomies"."type" IN ('Organization') ORDER BY title LIMIT 1
   (0.1ms)  SELECT "taxable_taxonomies"."taxable_id" FROM "taxable_taxonomies" WHERE "taxable_taxonomies"."taxable_type" = 'SmartProxy' AND "taxable_taxonomies"."taxonomy_id" IN (1)
   (0.1ms)  SELECT "taxable_taxonomies"."taxable_id" FROM "taxable_taxonomies" WHERE "taxable_taxonomies"."taxable_type" = 'SmartProxy' AND "taxable_taxonomies"."taxonomy_id" IN (2)
   (0.1ms)  SELECT "taxable_taxonomies"."taxable_id" FROM "taxable_taxonomies" WHERE "taxable_taxonomies"."taxable_type" = 'SmartProxy' AND "taxable_taxonomies"."taxonomy_id" IN (1)
   (0.1ms)  SELECT "taxable_taxonomies"."taxable_id" FROM "taxable_taxonomies" WHERE "taxable_taxonomies"."taxable_type" = 'SmartProxy' AND "taxable_taxonomies"."taxonomy_id" IN (2)
  SmartProxy Load (0.1ms)  SELECT "smart_proxies".* FROM "smart_proxies" WHERE "smart_proxies"."id" IN (2) AND (1=1)
=> [#<SmartProxy id: 2, name: "localhost", url: "http://localhost:8443", created_at: "2013-11-29 12:41:16", updated_at: "2013-11-29 12:41:16">]
[13] pry(main)> 
[14] pry(main)> 
[15] pry(main)> 
[16] pry(main)> SmartProxy.with_taxonomy_scope_override(Location.first, Organization.first).with_features("Puppet CA")
  Location Load (0.2ms)  SELECT "taxonomies".* FROM "taxonomies" WHERE "taxonomies"."type" IN ('Location') ORDER BY title LIMIT 1
  Organization Load (0.1ms)  SELECT "taxonomies".* FROM "taxonomies" WHERE "taxonomies"."type" IN ('Organization') ORDER BY title LIMIT 1
   (0.1ms)  SELECT "taxable_taxonomies"."taxable_id" FROM "taxable_taxonomies" WHERE "taxable_taxonomies"."taxable_type" = 'SmartProxy' AND "taxable_taxonomies"."taxonomy_id" IN (1)
   (0.1ms)  SELECT "taxable_taxonomies"."taxable_id" FROM "taxable_taxonomies" WHERE "taxable_taxonomies"."taxable_type" = 'SmartProxy' AND "taxable_taxonomies"."taxonomy_id" IN (2)
   (0.1ms)  SELECT "taxable_taxonomies"."taxable_id" FROM "taxable_taxonomies" WHERE "taxable_taxonomies"."taxable_type" = 'SmartProxy' AND "taxable_taxonomies"."taxonomy_id" IN (1)
   (0.1ms)  SELECT "taxable_taxonomies"."taxable_id" FROM "taxable_taxonomies" WHERE "taxable_taxonomies"."taxable_type" = 'SmartProxy' AND "taxable_taxonomies"."taxonomy_id" IN (2)
  SmartProxy Load (0.1ms)  SELECT "smart_proxies".* FROM "smart_proxies" INNER JOIN "features_smart_proxies" ON "features_smart_proxies"."smart_proxy_id" = "smart_proxies"."id" INNER JOIN "features" ON "features"."id" = "features_smart_proxies"."feature_id" WHERE "smart_proxies"."id" IN (2) AND "features"."name" IN ('Puppet CA') AND (1=1)
=> []

#3 Updated by Dominic Cleal about 5 years ago

I think that's an appropriate fix lzap, but it doesn't help with the associations case.

#4 Updated by Daniel Lobato Garcia about 5 years ago

Can't we just change it to

SmartProxy.with_features("Puppet CA").with_taxonomy_scope(@location,@organization) 

which doesn't call .unscoped?

#5 Updated by Dominic Cleal about 5 years ago

Maybe, it looks like it's giving the right results in a quick check, though I still see it making SQL queries around my Organization.current which is a bit worrying (the idea of the _override method is to ignore the current taxonomy), probably because .with_taxonomy_scope is called from the default_scope still.

#6 Updated by Dmitri Dolguikh about 5 years ago

I only see SmartProxy.with_taxonomy_scope use the location and organization that were passed in. Another difference between with_taxonomy_scope and with_taxonomy_scope_override scopes is that the former retrieves all children while the latter retrieves all parents of the organization and/or location that were passed in. I think we want the behaviour of SmartProxy.with_taxonomy_scope?

#7 Updated by Dmitri Dolguikh about 5 years ago

Correction: with_taxonomy_scope will indeed overlap with the default scope if Location.current and Organization.current are set. This doesn't seem to be a problem, however, as when multiple scopes are merged, duplicate attributes are removed, with the last one winning.

A couple of notes/questions:
- We may have bugs where with_taxonomy_scope is applied over the default scope.
- Perhaps it would be better (mostly for clarity/ease of maintenance sake) to explicitly call 'unscoped' in hosts_and_hostgroups_helper.rb (and similar) before using with_taxonomy_scope, ie:

SmartProxy.unscoped.with_features("DNS").with_taxonomy_scope(Location.last, Organization.last)

#8 Updated by Dmitri Dolguikh about 5 years ago

  • Status changed from New to Assigned
  • Assignee set to Dmitri Dolguikh

#9 Updated by Dmitri Dolguikh about 5 years ago

  • Status changed from Assigned to Ready For Testing

#10 Updated by Dominic Cleal about 5 years ago

  • Target version set to 1.8.4

#11 Updated by Dmitri Dolguikh about 5 years ago

  • Target version changed from 1.8.4 to 1.8.3

#12 Updated by Dmitri Dolguikh about 5 years ago

  • Target version changed from 1.8.3 to 1.8.4

#13 Updated by Dmitri Dolguikh about 5 years ago

  • Target version changed from 1.8.4 to 1.8.3

#14 Updated by Anonymous about 5 years ago

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

#15 Updated by Stephen Benjamin about 5 years ago

  • Related to Bug #5660: All OS Mirrors are Shown in the Dropdown list added

Also available in: Atom PDF