Skip to content

make pillar top_matches work with node groups - #47421

Merged
rallytime merged 5 commits into
saltstack:developfrom
bloomberg:nodegroup-topfile
May 9, 2018
Merged

make pillar top_matches work with node groups#47421
rallytime merged 5 commits into
saltstack:developfrom
bloomberg:nodegroup-topfile

Conversation

@mattp-

@mattp- mattp- commented May 1, 2018

Copy link
Copy Markdown
Contributor

What does this PR do?

the compound match evaluator to date relied callers to pre-evaluate nodegroups
into their decomposed state. in some places this wasn't happening. Rather than
fix every call site, teach compound_match to evaluate nodegroups in place.

It seems matchers were refactored to salt.utils.minions at some point but the
original minion.py matcher was not ported to use it. Given the hugeness of that
change, i've left as is and ported my fix to salt.utils.minions as well
instead.

What issues does this PR fix or reference?

this should fix #6602

Previous Behavior

nodegroup in compound didn't work.

New Behavior

it works.

Tests written?

Yes

Commits signed with GPG?

No

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@mattp-
mattp- requested a review from a team as a code owner May 1, 2018 21:00
@ghost
ghost self-requested a review May 1, 2018 21:00
the compound match evaluator to date relied callers to pre-evaluate nodegroups
into their decomposed state. in some places this wasn't happening. Rather than
fix every call site, teach compound_match to evaluate nodegroups in place.

It seems matchers were refactored to salt.utils.minions at some point but the
original minion.py matcher was not ported to use it. Given the hugeness of that
change, i've left as is and ported my fix to salt.utils.minions as well
instead.
@mattp-
mattp- force-pushed the nodegroup-topfile branch from 6bf5330 to 0f4b64b Compare May 2, 2018 14:15
Comment thread salt/minion.py Outdated

@isbm isbm May 7, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do it with less of coding:

words[0:0] = salt.utils.minions.nodegroup_comp(target_info['pattern'], nodegroups)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i realized that nodegroup_comp on failure returns '' and fixed that. I think [0:0] would still work, but i think its clearer intent leaving the if "contents:\nprepend" style of what the code is doing.

mattp- added 2 commits May 7, 2018 16:40
we may receive '' empty-string for nodegroup expansions, so we must account for
that safely.
@mattp-
mattp- force-pushed the nodegroup-topfile branch from e84e8d4 to c7b0891 Compare May 7, 2018 20:42
@mattp-

mattp- commented May 7, 2018

Copy link
Copy Markdown
Contributor Author

@rallytime i believe this should be good to go now

@mattp-
mattp- force-pushed the nodegroup-topfile branch from 2de0afe to f1dbb56 Compare May 8, 2018 13:42
@rallytime
rallytime merged commit ffe507d into saltstack:develop May 9, 2018
@corywright

Copy link
Copy Markdown
Contributor

Dreams can come true!

Thanks @mattp-!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to match on nodegroups to the compound matcher

5 participants