Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make pillar top_matches work with node groups #47421

Merged
merged 5 commits into from May 9, 2018

Conversation

mattp-
Copy link
Contributor

@mattp- mattp- commented May 1, 2018

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.
salt/minion.py Outdated
return False
# if we encounter a node group, just evaluate it in-place
decomposed = salt.utils.minions.nodegroup_comp(target_info['pattern'], nodegroups)
words = decomposed + words
Copy link
Contributor

@isbm isbm May 7, 2018

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
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-
Copy link
Contributor Author

mattp- commented May 7, 2018

@rallytime i believe this should be good to go now

@rallytime rallytime merged commit ffe507d into saltstack:develop May 9, 2018
@corywright
Copy link
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