Project

General

Profile

Actions

Bug #5106

closed

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

Added by Dominic Cleal almost 10 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Host creation
Target version:
Difficulty:
Triaged:
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 1 (0 open1 closed)

Related to Foreman - Bug #5660: All OS Mirrors are Shown in the Dropdown listClosedStephen Benjamin05/10/2014Actions
Actions #1

Updated by Stephen Benjamin almost 10 years ago

This also happens with OS Media in hosts_and_hostgroups_helper.rb:

@operatingsystem.media.with_taxonomy_scope_override(@location,@organization)
Actions #2

Updated by Lukas Zapletal almost 10 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)
=> []
Actions #3

Updated by Dominic Cleal almost 10 years ago

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

Actions #4

Updated by Daniel Lobato Garcia almost 10 years ago

Can't we just change it to

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

which doesn't call .unscoped?

Actions #5

Updated by Dominic Cleal almost 10 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.

Actions #6

Updated by Anonymous almost 10 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?

Actions #7

Updated by Anonymous almost 10 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)

Actions #8

Updated by Anonymous almost 10 years ago

  • Status changed from New to Assigned
  • Assignee set to Anonymous
Actions #9

Updated by Anonymous almost 10 years ago

  • Status changed from Assigned to Ready For Testing
Actions #10

Updated by Dominic Cleal almost 10 years ago

  • Target version set to 1.8.4
Actions #11

Updated by Anonymous almost 10 years ago

  • Target version changed from 1.8.4 to 1.8.3
Actions #12

Updated by Anonymous almost 10 years ago

  • Target version changed from 1.8.3 to 1.8.4
Actions #13

Updated by Anonymous almost 10 years ago

  • Target version changed from 1.8.4 to 1.8.3
Actions #14

Updated by Anonymous almost 10 years ago

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

Updated by Stephen Benjamin almost 10 years ago

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

Also available in: Atom PDF