puppetlabs / puppetlabs-node_manager

Create and manage PE node groups as resources.
Apache License 2.0
10 stars 21 forks source link

(CAT-1731) add rules tests #81

Closed jonathannewman closed 1 month ago

jonathannewman commented 2 months ago

Summary

Within the Puppet Enterprise UI console the concept of pinned nodes allows more complex rules to be expressed while including pinned nodes.

Pinned nodes are formed by having a top level "or" clause, with expressions in the form

['=', 'name', 'hostname']

Prior to this change, the code would not properly maintain pinned nodes, nor correctly handle merging expressions like:

['and',
  ['~',
    ['fact', 'pe_server_version'],
    '.+']]

with

['or', ['~',
    ['trusted', 'extensions', '1.3.6.1.4.1.34380.1.1.9812'],
    '^puppet/']]

Incorrectly combining them into an and clause when logically they should be an "or" clause.

With this change, pinned nodes are separated our from the other rules and then recombined later (if they are present) with a top-level "or" clause.

Test are added to demonstrate the behaviors.

Additional Context

Add any additional context about the problem here.

Related Issues (if any)

Mention any related issues or pull requests.

Checklist