-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
tpldir calculation is broken in some cases #56410
Comments
Any news on this? Still hitting this bug in random places - driving people crazy where things unexpectedly fail |
@mlasevich there is a long discussion on this and I can put this into the Magnesium release cycle as a possibility of fixing, but I cannot commit unless there is some help from the community to submit a PR perhaps @terminalmage? |
What is the concern? I can take a stab, but I am a bit unclear about the larger context of this function and worried that its intertwined with other things I am not seeing... Thus would prefer to have someone who is more familiar with the code look at it. |
@mlasevich you are of course welcome to take a stab at it! I was looking through the comments on the closed issue you linked and there was talk of many things, so it seems to have gone in many directions, and yes I also want to be sure you have someone available to look through the code with you, that is my entire intent. I hope that is suitable. |
I tried to tackle this (or something similar) but ended up breaking behavior that others relied upon. I'll try to dig up the PR and issue on Tuesday. Want to make sure we don't make the same mistakes this time around. 😄 |
Thank you @terminalmage and if @mlasevich you two want to work together I am happy to help set up time and use our Community Slack or Zoom to help facilitate or @cassandrafaris can help as well :) |
This is the original PR, right? #55434 and this is commit that it reverts 7c28995 |
@sagetherage No, that commit is actually from my original PR (#55434) which was reverted by @dwoz in #56341 per the conversation in #56119 (comment). Note that the act of reverting added some documentation. If any changes are made, we want to make sure that we are not changing behavior in such a way that it will create further confusion (or conflict with the docs). |
oh gosh! look at that, I am not correct! Thank you for setting me straight. Yes, I agree. |
Ok, I actually just started poking at it (without looking at the above first) - I think that entire block of logic is way more complicated than it needs to be. From what I see the core issue is how to determine the "root" of the sls template in tmplpath - and there are all sorts of tricks used to do that - which are source of the bugs - when the reality is - there are only two possibilities here - either it is whatever is in sls or whatever is in sls plus "init" - am I missing something? Are there any scenarios where sls and tmplpath are completely different? |
made the PR instead |
* Cleanup calculation of template sls/tpl context Fixes #56410 * fix string formatting * Add unit test that works against old version (with bugs) * Updated unit tests with non-buggy values and fix found bugs * cleanup unit tests to test underlying function * remove old unit test components no longer used * Cleanup * More Cleanup * More cleanup. Add Mock to test.support.unit * Add changelog entries * Fix Mockery * Import order fix * Handle backslashes in sls names under *nix * Cleanup * Make sure we return a dictionary from jinja.load_map * Fix scenario when sls is empty but present * Touched another file - Cleanup to make pre-commit happy * Adding variables to docs * Fix expected tplpath value to be OS specific and note so in docs * removing comments from imports as per pre-commit * removing comments from imports as per pre-commit * Put slsvars changes behind a feature flag * Better documentation for enable_slsvars_fixes feature flag * Fix test that should be skipped on windows Co-authored-by: Michael "M3" Lasevich <[email protected]> Co-authored-by: Sage the Rage <[email protected]> Co-authored-by: Daniel A. Wozniak <[email protected]> Co-authored-by: Shane Lee <[email protected]>
Description of Issue
Buggy code is here:
salt/salt/utils/templates.py
Lines 127 to 131 in 84c6070
Short version, if name of the directory containing the sls is contained in sls name, tpldir calculation will return wrong result.
Slightly longer version, it seems to be trying to find the tplpath by looking for last occurrence of slspath in template name - without realizing it may occur later in the full template path.
This can be fixed by simply adding the basename of the template to the slspath - although I am not really sure what is the point of this code - seems like a complicated way to get what you already have in slspath....
Setup
setup as file x/x.sls
Steps to Reproduce Issue
.
- which is incorrectVersions Report
bug is still present in the master branch as evident by code link above
The text was updated successfully, but these errors were encountered: