Jira (PUP-8405) Knock-out-prefix fails with more than 3 merges

13 views
Skip to first unread message

Henrik Lindberg (JIRA)

unread,
Jan 30, 2018, 12:44:03 PM1/30/18
to puppe...@googlegroups.com
Henrik Lindberg moved an issue
 
Puppet / Bug PUP-8405
Knock-out-prefix fails with more than 3 merges
Change By: Henrik Lindberg
Method Found: Needs Assessment
Issue Type: Task Bug
Key: HI PUP - 595 8405
Project: Hiera Puppet
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
Jan 30, 2018, 12:45:03 PM1/30/18
to puppe...@googlegroups.com

Ryan Struber (JIRA)

unread,
Jan 30, 2018, 12:50:03 PM1/30/18
to puppe...@googlegroups.com
Ryan Struber updated an issue
Change By: Ryan Struber
When defining multiple levels of hierarchy in hiera.yaml (more than 3), and requesting hiera to lookup a key that is found on more than 3 levels, and lookup options for that key are configured to merge deep with a knockout prefix, the merge fails to knockout the key matching the higher precedence knockout.

Steps to reproduce:

{code:yaml}
hiera.yaml:
 version: 5
 defaults:         
   datadir: data
   data_hash: yaml_data

 hierarchy:
   - name: node specific data
     path: node/%{::site.node}.yaml

   - name: product data
     path: product/%{::site.product}.yaml

   - name: os data
     path: os/%{::os.family}.yaml

   - name: global data
     path: common.yaml

common.yaml:
  lookup_options:
    classes:
      merge:
        strategy: deep
        knockout_prefix: --
  classes:
    - profiles::motd
    - profiles::network

os/RedHat.yaml:
  classes:
    - profiles::yum

product/product.yaml
 classes:
   - profiles::application

node/node.yaml:
 classes:
   - profiles::puppet-agent
   - --profiles::network
   - network
{code}

*Expected*

{code:java}
puppet lookup --knock-out-prefix '--' --merge deep classes
---
- profiles::motd
- profiles::yum
- profiles::application
- network
{code}

*Actual*

{code:java}
puppet lookup --knock-out-prefix '--' --merge deep classes
---
- profiles::motd
- profiles::network
- profiles::yum
- profiles::application
- network
{code}

Removing a layer from the hierarchy causes the merge to behave as expected. The difference being:

{code:java}
puppet lookup --knock-out-prefix '--' --merge deep classes | grep 'Found key:' | wc -l
4
{code}
vs
{code:java}
puppet lookup --knock-out-prefix '--' --merge deep classes | grep 'Found key:' | wc -l
3
{code}


Verified in puppet version 4.10.0, 4.10.9

Ryan Struber (JIRA)

unread,
Jan 30, 2018, 12:51:04 PM1/30/18
to puppe...@googlegroups.com
Verified in puppet version *Affect Versions*
Puppet
 4.10.0 ,
Puppet
 4.10.9

Ryan Struber (JIRA)

unread,
Jan 30, 2018, 12:51:05 PM1/30/18
to puppe...@googlegroups.com
* Affect Affected  Versions*
Puppet 4.10.0
Puppet 4.10.9

Ryan Struber (JIRA)

unread,
Jan 30, 2018, 12:52:02 PM1/30/18
to puppe...@googlegroups.com
* Verified Affected Versions*
Puppet 4.10.0
Puppet 4.10.9

Ryan Struber (JIRA)

unread,
Jan 30, 2018, 12:52:03 PM1/30/18
to puppe...@googlegroups.com
*Verified Affected Versions*
Puppet 4.10.0
Puppet 4.10.9

Puppet 5.3.1

Thomas Hallgren (JIRA)

unread,
Jan 30, 2018, 4:15:04 PM1/30/18
to puppe...@googlegroups.com
Thomas Hallgren commented on Bug PUP-8405
 
Re: Knock-out-prefix fails with more than 3 merges

This is per design. A knock-out prefix is only capable of doing one knock-out. Once the knock-out is performed, it's not remembered.

Ryan Struber (JIRA)

unread,
Jan 30, 2018, 4:53:02 PM1/30/18
to puppe...@googlegroups.com
Ryan Struber commented on Bug PUP-8405

I'm not sure I got the concept across correctly given your comment. I'm not reporting the knock-out is failing to perform multiple times. Rather if you merge together too many levels, knock-out fails to perform at all.

Ryan Struber (JIRA)

unread,
Jan 30, 2018, 4:56:02 PM1/30/18
to puppe...@googlegroups.com
Ryan Struber updated an issue
Change By: Ryan Struber
   -  -- profiles::network

Thomas Hallgren (JIRA)

unread,
Jan 30, 2018, 5:12:03 PM1/30/18
to puppe...@googlegroups.com
Thomas Hallgren commented on Bug PUP-8405
 
Re: Knock-out-prefix fails with more than 3 merges

I understand that, but the knock-out is not remembered after a merge. It's a concept implemented by the underlying deep_merge operation and forgotten once a merge has taken place. It doesn't matter if values were actually knocked out or not during that merge. The knock-out is only applicable to the immediate merge with the next level, not with levels beyond that.

Thomas Hallgren (JIRA)

unread,
Jan 30, 2018, 5:15:02 PM1/30/18
to puppe...@googlegroups.com

Running the lookup with a --explain will provide information on what happens in each merge. The knock-outs are not specifically reported but you see the inputs and the result of each individual merge.

R.I.Pienaar (JIRA)

unread,
Jan 31, 2018, 2:10:02 AM1/31/18
to puppe...@googlegroups.com
R.I.Pienaar commented on Bug PUP-8405

Imo this makes this feature more or less useless. It works too differently and have very surprising restrictions orthogonal to the rest of hiera

If it can’t be fixed it should be removed rather than just be super weird

Henrik Lindberg (JIRA)

unread,
Jan 31, 2018, 4:03:04 AM1/31/18
to puppe...@googlegroups.com

Is it true to say that the desired (unsurprising behaviour) would be that a knockout knocks out a key if it was present in the result from lower precedence entries in the hierarchy?

R.I.Pienaar (JIRA)

unread,
Jan 31, 2018, 4:05:03 AM1/31/18
to puppe...@googlegroups.com
R.I.Pienaar commented on Bug PUP-8405

Personally to me that would be less surprising yes

Thomas Hallgren (JIRA)

unread,
Jan 31, 2018, 6:13:02 AM1/31/18
to puppe...@googlegroups.com

We have several options:

1. Change the current behavior to something else, like knocking out keys of lower precedence than were the lookup_option was introduced. Question is though, what this precedence means given that a lookup_option that is found in a module actually has impact on entries found at higher levels. I.e. an environment can override a key defined in a module without overriding a lookup_option for that same key. The option will still be in effect but now be applied on the key from the environment instead. In any case, it will be a breaking change.

2. Remove the knockout_prefix altogether. Again, breaking change.

3. Deprecate the knockout_prefix and introduce something better. A filter proposal discussed before was tabled due to bad complexity/demand ratio.

4. Do nothing and instead give examples and recommendations on how lookup functions can be written in Puppet to achieve the desired results.

5. Something else...

Henrik Lindberg (JIRA)

unread,
Jan 31, 2018, 9:53:02 AM1/31/18
to puppe...@googlegroups.com

But... the knockout prefix in option just turns on the feature and specifies what the prefix is. Don't think it is ever an issue to use different knockout prefixes for the same key. So... it is really a matter of merging the data and knocking out the value if there is an "anti-value"... no?

Thomas Hallgren (JIRA)

unread,
Jan 31, 2018, 10:13:02 AM1/31/18
to puppe...@googlegroups.com

Yes, that's correct. But if we start talking about layers and precedence, then users might thing that the option is turned on in the module layer but have no effect on higher layers, which would be a false assumption but perhaps the distinction between options and values and their precedence is described well enough already.

In any case, changing the behavior so that anti-values survive when they don't knock things out is a breaking change. We've discussed this before and decided it was not a direction we'd want to go. Please see

PUP-7438 .

Henrik Lindberg (JIRA)

unread,
Jan 31, 2018, 1:55:03 PM1/31/18
to puppe...@googlegroups.com

I have no worry over the lookup_options here.

The knockout_prefix feature is kind of useless as it stands.
Although the filter capability we discussed is nice it is not as convenient as the knockout prefix since you see the later in your data.

The

PUP-7438 ticket was closed in the big triage, don't think all that much thought went into that decision.

We may want to change the behavior for puppet 6 (it is breaking, but I suspect the change will go unnoticed, since use of knockout that works will continue to work, so only affects those that may have garbage knockouts that they really did not want).

Ryan Struber (JIRA)

unread,
Jan 31, 2018, 6:00:10 PM1/31/18
to puppe...@googlegroups.com
Ryan Struber commented on Bug PUP-8405

Just an aside, we've decided to move forward getting the difference of an exclusion key:

classes:
  - network
  - agent
 
exclude_classes:
  - network
 
$classes = [ lookup(classes) - lookup(exclude_classes) ]

Perhaps an example (more flushed out) like this in docs could be helpful given the functionality confusion.

Josh Cooper (JIRA)

unread,
Feb 8, 2018, 4:19:04 PM2/8/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Sub-team: Language
This message was sent by Atlassian JIRA (v7.5.1#75006-sha1:7df2574)
Atlassian logo

Josh Cooper (JIRA)

unread,
Feb 8, 2018, 4:19:05 PM2/8/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Platform Core

Dominik Schuster (JIRA)

unread,
Jul 12, 2018, 6:44:02 AM7/12/18
to puppe...@googlegroups.com
Dominik Schuster commented on Bug PUP-8405
 
Re: Knock-out-prefix fails with more than 3 merges

Thanks Ryan Struber that really unlocked me from the problem.

This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Kenyon Ralph (JIRA)

unread,
Nov 27, 2018, 5:29:02 PM11/27/18
to puppe...@googlegroups.com
Kenyon Ralph commented on Bug PUP-8405

This seems to be a duplicate of PUP-7428 (and this is a bug that just bit me as well, trying to remove a class in a node that's added by the common level).

Josh Cooper (Jira)

unread,
Mar 8, 2022, 12:48:03 PM3/8/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Froyo
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo

David McTavish (Jira)

unread,
Mar 8, 2022, 12:59:03 PM3/8/22
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Apr 27, 2022, 12:50:02 AM4/27/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Component/s: Hiera & Lookup

Alvin Rodis (Jira)

unread,
May 24, 2022, 4:57:02 AM5/24/22
to puppe...@googlegroups.com
Alvin Rodis updated an issue
Change By: Alvin Rodis
Zendesk Ticket Count: 1
Zendesk Ticket IDs: 47851

Alvin Rodis (Jira)

unread,
May 24, 2022, 4:57:03 AM5/24/22
to puppe...@googlegroups.com
Alvin Rodis updated an issue
Change By: Alvin Rodis
Labels: jira_escalated

Stephen Jennings (Jira)

unread,
May 24, 2022, 5:00:05 AM5/24/22
to puppe...@googlegroups.com

Stephen Jennings (Jira)

unread,
May 24, 2022, 5:01:02 AM5/24/22
to puppe...@googlegroups.com
Stephen Jennings commented on Bug PUP-8405
 
Re: Knock-out-prefix fails with more than 3 merges

Increase priority to major (customer sat). Unclear as to this or https://tickets.puppetlabs.com/browse/PUP-7409 are primary issues

Reply all
Reply to author
Forward
0 new messages