Details
-
Bug
-
Status: Needs Information
-
Normal
-
Resolution: Unresolved
-
None
-
None
-
None
-
Reviewed
-
38759
-
1
Description
Consider the following hiera structure:
host.yaml
stuff:
|
- ---alpha
|
- ---beta
|
- gamma
|
datacenter.yaml
stuff:
|
- alpha
|
global.yaml
stuff:
|
- beta
|
Where the hierarchy is:
:hierarchy:
|
- host
|
- datacenter
|
- global
|
What you'd expect is that a hiera_hash() call from the host matching the host.yaml is that alpha and beta would be knocked out, leaving just gamma in the resulting array. Instead, both gamma and beta are left in.
This seems to be because the deep merge is performed in the most specific to least specific order, and the deep_merge gem will delete knockout values from the source array if they match destination values or even if they don't match anything.
Because they are removed from the array, when the next array is merged (an array that may contain a value to be knocked out), the knockout value is gone.
This likely also adds a side-effect (I haven't tested, but it seems correct) that if a value exists multiple times in various files, it is only knocked out in the "closest" array to the knockout value, and is then promptly added back in when seen again.
A possible solution to this would be to reverse the processing order for deep_merge so that the knockouts are processed from least specific to more specific, but I suspect there will be tons of other side effects. Another possibility is to always keep knockout values throughout the merging, and then have a final pass after the final merge to remove the knockout values. This would allow for processing to continue in the current order.
Attachments
Issue Links
- relates to
-
PUP-8405 Knock-out-prefix fails with more than 3 hierarchy levels
-
- Accepted
-