Project

General

Profile

Bug #8551

Multiple overrides in inherited Host Groups causing multiple values on host.

Added by Matthew Little over 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Smart Variables
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

After upgrading to 1.7.0 I have some hosts inside nested Host Groups who are either getting incorrect override values, or are getting multiple values for overrides.
Example:
Host Group:
/Base/Webfarm has override for class parameter _attributes in class opsview::monitored
/Base/Webfarm/Backup has override for the same parameter with a different value.

Hosts in /Base/Webfarm/Backup will get the override parameter from /Base/Webfarm.
If the setting "Merge overrides" is checked, then the hosts will get both override values from Base/Webfarm and base/Webfarm/Backup
The duplicate behavior occurs regardless of the "Avoid duplicates" setting as well.

Here is a Pastebin of the YAML for a host with both values for the parameter VCENTER: http://pastebin.com/c3uhFVm4
The value is overridden to 'vcenter' in Base/Webfarm and overridden to 'test-vcenter' in Base/Webfarm/Backup
Please let me know if I can provide any further information to help with the issue.

Associated revisions

Revision daf34ae7 (diff)
Added by Ori Rabin over 4 years ago

Fixes #8551 - use most specific matcher for inherited hostgroups

Host recieves correct smart_class_parameter value when multiple overrides for
inherited host groups exist for parameter.

Revision 04495720 (diff)
Added by Ori Rabin over 4 years ago

Fixes #8551 - use most specific matcher for inherited hostgroups

Host recieves correct smart_class_parameter value when multiple overrides for
inherited host groups exist for parameter.

(cherry picked from commit daf34ae7195fda204ff6c9afdec8f14e4ce4f795)

History

#1 Updated by Ori Rabin over 4 years ago

  • Category set to Smart Variables
  • Status changed from New to Need more information

I would appreciate if you can provide some more information for the two problems you mentioned:

1) Hosts in /Base/Webfarm/Backup will get the override parameter from /Base/Webfarm
can you please provide the order of overrides and the matchers with their values?

2) The duplication - it looks from the yaml that you have a parameter "_attributes" that is an array and the elements in it are hashes?
I'm trying to understand how exactly the values look like.
Avoid duplicates is used so if you have [name: a] twice you will only see one of them.
If your elements are [name: a] and [name: b] then it isn't a duplicate value.
Can you please send the values of the overrides for VCENTER as they appear in the "value" box in "_attributes"?

#2 Updated by Dominic Cleal over 4 years ago

  • Legacy Backlogs Release (now unused) set to 29

Just adding to the 1.7.1 tracker as this sounds like a regression.

#3 Updated by Dominic Cleal over 4 years ago

  • Status changed from Need more information to New

I could reproduce this quite easily with a similar setup to the one that Matthew describes:

  1. Three host groups: Base, Base/Webfarm, Base/Webfarm/Backup
  2. Base environment set, others inherit
  3. 'monitor' Puppet class with one $_attributes parameter, defaults to []
  4. monitor Puppet class assigned to Base host group
  5. $_attributes parameter set to 'array' type
  6. hostgroup=Base/Webfarm matcher with value [{"name":"VCENTER","value":"vcenter"}]
  7. hostgroup=Base/Webfarm/Backup matcher with value [{"name":"VCENTER","value":"test-vcenter"}]
  8. one host with host group set to Base/Webfarm/Backup

Everything else is "default", i.e. no changes to parameter defaults, no merging or anything enabled. Then if I preview the YAML, I see:

---
classes:
  monitor:
    _attributes:
    - name: VCENTER
      value: vcenter
parameters:
  puppetmaster: foreman.example.com
  hostgroup: Base/Webfarm/Backup

#4 Updated by Dominic Cleal over 4 years ago

Arrays and hashes seem irrelevant too, I can reproduce it with a string data type and the same matchers.

#5 Updated by Dominic Cleal over 4 years ago

It seems to just match anything. If I add fqdn=foobar (not its name) with another value, my host gets that new value.

#6 Updated by Ori Rabin over 4 years ago

  • Assignee set to Ori Rabin

#7 Updated by The Foreman Bot over 4 years ago

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

#8 Updated by Dominic Cleal over 4 years ago

Dominic Cleal wrote:

It seems to just match anything. If I add fqdn=foobar (not its name) with another value, my host gets that new value.

This is incorrect, I can't replicate it and it doesn't make sense from the code. The issue is just when two overrides exist for two host groups within the same hierarchy - it's not preferring the more specific host group match.

#9 Updated by Ori Rabin over 4 years ago

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

Also available in: Atom PDF