Issue #7423 has been updated by Henrik Lindberg.
Nick Fagerlund wrote: > Ha! I sense a kindred spirit, here. :) > ### Can node 'default' inherit? > > Yes. Not only does it work, but I can see an argument for actually using that > feature, although node inheritance in general is scary and kind of hateful. Makes sense to me as well. I just wanted to know if it was supported or was a special case. > ### Circular inheritance > > Not sure what to say about this one. I'm guessing the grammar allows it, > right? I assumed so - did not drill down into the logic, at some point it needs to be detected, or user will just have to wait for the stack overflow :) > ### Ambiguous nodes > > Yes, and I think that's by design. The most specific one wins. If the > certname is in the form of a dotted list of words (like a fqdn), it'll keep > lopping chunks off the end and checking again for a node definition. (That > is, only two of the names in your example can match a given node, because of > that 'internal' in the middle.) > > If I'm remembering right, [this happens with external nodes > too](http://docs.puppetlabs.com/guides/external_nodes.html) (possibly not at > the same precision?), but Dashboard doesn't respect that, so I'd have to come > up with a custom ENC to test it and I'm not ready to do that yet. ok, that is clear - I will let geppetto do the same - shortest matching name wins, and if there are more than one it is ambiguous. > ### Inheritance and regex nodes > > Ask someone in the office about the noise I made when I got this to work. And > the face Nigel made when I told him about it. > > Regex node names can be on either side of the `inherits` statement, but to > use them on the right side, you need to: > > - Put the name (that is, the regex, not some random string the regex would > match) in quotes instead of slashes. > - Edit the stringified regex to delete all instances of characters on a > secret list of characters. I don't know the whole list yet, but it includes > backslashes and square brackets. > > So, this works: > > node /ha\w\wagent/ { > notify {'in node ha\w\wagent (regex)':} > } > node /haw\w\waster/ inherits "hawwagent" { > notify {'in node haw\w\waster (regex)':} > } > > I probably don't have to specify why I'm appalled. Also, this means that > (ignoring inheritance for now) if you have two nodes whose regexen are > different but result in the same string once you mutilate them, catalog > requests will fail. That one's obviously a bug, and I should probably file it > in a minute. O|o <- this is just insane... Is inherits with regexp on the right side ever used for any otherwise non achievable task? If important to inherit a node that is specified with a regexp "name", it would be far better to separate the concepts of "matches" and "identity". i.e. something like node /*.\.com/ as dotcomnode { } node x inherits dotcomnode { } and removing the ability to refer to the regexp as the identity. Does it work in reverse - I mean - what happens if a regexp on the right matches several nodes (with non regexp names). Does this work at all, or is the comparison then made with the magically stringified regexp as id? e.g. node a {} node ab {} node abc {} node x inherits /ab.*/ {} > ### Can ‘default’ be matched with regexp? > > Alas, it can. This smells like a bug. I am fine either way, as long as it is defined to work (or not work). > ### Linking to non existing nodes > > The part about regexen matching is sort of answered above: regex nodes are > referenced by the stringified and mutilated regex rather than by match, and > you can inherit a node whose regex doesn't match the incoming node request at > all. (If two regex nodes DO both match the request, you have an order > dependency, and one of them will win.) Is it specified which one will win? or, just the one that the logic happens to check first? > If you try to inherit a node that isn't defined, the catalog request just > fails completely. Something like this: > > err: Could not retrieve catalog from remote server: Error 400 on SERVER: > Could not find parent resource type '/hawk/' of type node in fakenvironment > at /etc/puppet/manifests/site.pp:18 on node hawkmaster.magpie.lan > warning: Not using cache on failed catalog > err: Could not retrieve catalog; skipping run > ok, so static validation of this is of value. > ### In conclusion > > Damn. +1 ---------------------------------------- Bug #7423: unclear node inheritance semantics https://projects.puppetlabs.com/issues/7423 Author: Henrik Lindberg Status: Unreviewed Priority: Normal Assignee: Category: parser Target version: 2.6.x Affected Puppet version: Keywords: parser node inheritance semantics easeofuse documentation usability Branch: While working with Geppetto to provide validation and incremental feedback while editing, I entered into the realm of node inheritance. By looking at what is allowed in the grammar I have several questions regarding the semantics and legality of some of the possible constucts. I have no clue if the grammar should be more retrictive (i.e. these are grammar bugs), or if the documentation should be expanded to declare how it is supposed to work (or for that matter if any of these constructs actually work ;) - they seem to be allowed from a grammar standpoint. (If you prefer to read this online formatted a bit better - see https://github.com/cloudsmith/geppetto/wiki/Semantic-Issues-regarding-Node-Inheritance) ### Can node ‘default’ inherit ? A node declared as node default { } is used for hosts that do not match. Is it possible for such a node to also inherit ? node default inherits x { } ### Circular inheritance Is obviously not allowed. Depending on the semantics for inheritance using regular expressions, there can be some surprises that are introduced when additional classes are added (and they happen to match). ### Ambiguous Nodes ? Are simple and qualified names allowed to overlap? Is it ok to declare all of these: node bugtracker { } node ‘bugtracker.myorg.com’ { } node ‘bugtracker.internal.myorg.com’ { } … or is this an error? ### Ambiguous inheritance A node can be declared with a simple name (e.g. `bugtracker`), or a fully qualified name (`‘bugtracker.myorg.com’`). When inheriting it is possible to use both simple and qualified name - what happens when there are several to choose from e.g. `‘bugtracker.myorg.com’`, `‘bugtracker.internal.myorg.com’`. What happens if a node is declared with: node x inherits bugtracker { } ### Nodes matching with regular expressions A node can match using a regular expression: node /web-([0-9]*).example.com$/ {} How is inhertitance of such a node possible? This syntax is allowed by the parser: node webservers inherits /web-([0-9]*).example.com$/ {} What does this mean? Is the inheritance to a node with an identical (matching) regexp (i.e. equal regexp string), or to equivalently matching regexps, or it is it applied to the regexp as a string? Or, are nodes defined with regexp ‘name’ not included in the matching? This is very confusing... ### Can ‘default’ be matched with regexp? Is this sensical? node /defa.*/ { } ### Linking to non existing nodes Since inheritence can be expressed with regular expressions and string expressions - what happens if there is no match? Is this an error, or simply that there is nothing to inherit at this particular moment? If the answer is that it means that same as not having specified inheritance, then does the same rule apply if a name is used? E.g. 1. No xyz is known ```ruby node a inherits xyz { } ``` 2. Regexp does not match ```ruby node a inherits /x.*/ { } ``` 3. Variably $y is not set to "yz" ```ruby node a inherits "$y" ``` -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
