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

Only compile the template contents if they evaluate to True #33679

Merged
merged 2 commits into from
Jun 2, 2016

Conversation

terminalmage
Copy link
Contributor

When getting all the top files for the various environments, those
environments without a top file will return False when we attempt to
cache the file. Passing a boolean to compile_template() will result
in an error being logged, since we are invoking the function incorrectly
(it expects the template data to be a string).

Since a False return from caching the file means that it does not
exist, this commit will only run compile_template() when the
contents evaluate to True.

Resolves #33424.

@thatch45 Is this a sane fix? Is there any potential breakage that could occur
by leaving environments lacking a top file (or I guess, those with top files of
zero length) out of the return data from get_tops()? I can't see any.

When getting all the top files for the various environments, those
environments without a top file will return ``False`` when we attempt to
cache the file. Passing a boolean to ``compile_template()`` will result
in an error being logged, since we are invoking the function incorrectly
(it expects the template data to be a string).

Since a ``False`` return from caching the file means that it does not
exist, this commit will only run ``compile_template()`` when the
contents evaluate to ``True``.

Resolves saltstack#33424.
@thatch45
Copy link
Contributor

thatch45 commented Jun 1, 2016

Yes, this looks good to me, your logic is sound

@cachedout
Copy link
Contributor

@terminalmage Could you look at the test failures? I think I wrote some of those so I can help if needed.

@terminalmage
Copy link
Contributor Author

Looking now.

Rather than excluding them from the get_tops() return data at all, just
populate them with empty dictionaries. This makes it easier to unit test
things like merge order, while still being functionally the same as
exlcluding the saltenv from get_tops() altogether.
@terminalmage
Copy link
Contributor Author

Should be fixed. Instead of leaving the environments out of the return dict altogether, I'm just appending empty dictionaries to them. It seems from the failing unit tests that this was the original intent, and doing so both does not impact the highstate logic while making it easier to unit test things like top file merging.

@cachedout
Copy link
Contributor

Solid. +1

@cachedout cachedout merged commit 996ff56 into saltstack:2015.8 Jun 2, 2016
@terminalmage terminalmage deleted the issue33424 branch July 7, 2016 18:59
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.

3 participants