Uploaded image for project: 'Hiera'
  1. Hiera
  2. HI-223

Hiera 'deeper' merge knockout only knocks out from closest array

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Needs Information
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Template:
    • CS Priority:
      Reviewed
    • Zendesk Ticket IDs:
      38759
    • Zendesk Ticket Count:
      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

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              anoonan Andrew Noonan
              Votes:
              6 Vote for this issue
              Watchers:
              15 Start watching this issue

                Dates

                Created:
                Updated:

                  Zendesk Support