-
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
Release notes for v3000 do not mention changes to slspath
variable
#56119
Comments
+1 I was about to create an issue for the exact same problem. Good find with the tplpath variable. |
Add me a +1. This breaks previously working SLS files and it is frustrating to have this happen with ZERO indication. |
+1. Sure do love these breaking changes. |
For |
A quick patch:
{% if grains.saltversion == "3000" %}
patch:
pkg.installed
slspath_patch:
file.patch:
- name: '{{ grains.saltpath }}'
- source: salt://patches/files/3000-slspath.diff
- strip: 2
- require:
- pkg: patch
restart_salt_minion:
cmd.run:
- name: 'salt-call service.restart salt-minion'
- bg: true
- onchanges:
- file: slspath_patch
{%- endif %}
diff --git a/salt/utils/templates.py b/salt/utils/templates.py
index d026118269..98092a9d79 100644
--- a/salt/utils/templates.py
+++ b/salt/utils/templates.py
@@ -122,6 +122,8 @@ def wrap_tmpl_func(render_str):
slspath = context['sls'].replace('.', '/')
if tmplpath is not None:
context['tplpath'] = tmplpath
+ if not tmplpath.lower().replace('\\', '/').endswith('/init.sls'):
+ slspath = os.path.dirname(slspath)
template = tmplpath.replace('\\', '/')
i = template.rfind(slspath.replace('.', '/'))
if i != -1: Run |
Just hit this wall too and changed all my |
The commit: As all (relevant) unittests reported success, it may be a good idea to harden the variables with unittests. |
This is tangential but I was wondering why slspath and tpldir were the same in previous versions. I have almost filed an issue in the past to see if slspath could be updated to do what it does now, and document tpldir |
I don't understand how is this going to be resolved. Is the change to |
Since this has gone completely undocumented AND is a backwards incompatible change, I'd vote for reverting it to the previous behaviour and only then announce it as being deprecated and change it in the second next release. Nothing else does make any sense. |
Looking into this @dkacar-oradian @dhs-rec we will add this to the this week's Community Open Hour on Thursday at 11 AM Mountain and get more details in this ticket. Apologies! I didn't see this early, Monday was a US holiday and simply catching up, not to defend or give you and excuse, we need to hear from you and deal with this ASAP, simply giving context for the lack of a more prompt response. |
The change needs to be reverted and go through a proper deprecation path. |
saltstack/salt#56119 slspath ==> tpldir
saltstack/salt#56119 slspath ==> tpldir
That change should absolutely not be reverted. It was a bugfix. From the documentation:
"the path to the current SLS file". Not a directory. |
Yeah, but the point is: People are using this, now, in the way it was implemented, not the way it was documented. Changing the behaviour now, regardless of being a bugfix or a feature, breaks those people's code. Period. |
|
Yeah, I agree. The correct move here is to build out the documentation, not to break EDIT: I've changed my mind, see below. |
@dhs-rec And some people are expecting |
After looking at the code again, the bugfix didn't even restore the documented behavior, since the path to the SLS file has already at that point had its Given that swing-and-miss on the bugfix, it's probably better to proceed with reverting in #56341, provided that the following is also added to that PR:
|
Perhaps GitHub should add 🤦 as a reaction option.
@terminalmage with what? Is "change should absolutely not be reverted" no longer your position? Perhaps you should edit or hide that comment for clarity.
In which case I think |
These are all excellent points (especially the one regarding the proposed new reaction type 😄), and I went back and edited my earlier comment. |
Another observation - In e.g. a Update: if I'm reading the comment linked below correctly - |
FYI: I did some research on how various Jinja variables behave inside of |
Another thing I noticed about this change is it made things in-consistent. With the change, running state with the When the change is reverted both of the above scenarios return In any case, for the |
closing since resolved in 3000.1 with #56341 seems like there might be some discussion that could occur in a SEP if we want to change and properly deprecate things here. |
For those who care about this - be careful switching to |
Description of Issue
Release notes for v3000 do not mention changes to
slspath
variable by #55434 / #55433 , which previously returned the parent directory instead of the path to the state file itself.This functionality appears to be covered by the
tpldir
variable, but this is not documented on https://docs.saltstack.com/en/latest/ref/states/vars.html.Can both the v3000 release notes and the SLS Template Variable Reference be updated to make this more visible to others?
Setup
Tree:
root.sls
Steps to Reproduce Issue
Output:
Replacing
slspath
withtpldir
resolves the issue, but this is not an obvious fix.Versions Report
The text was updated successfully, but these errors were encountered: