-
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
All of Salt's loaders now accept loaded_base_name
& Only functions defined on the modules being loaded will be added to the lazy loader
#62189
All of Salt's loaders now accept loaded_base_name
& Only functions defined on the modules being loaded will be added to the lazy loader
#62189
Conversation
123b47e
to
0be65f0
Compare
re-run full all |
5e6bb1e
to
94e39ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of questions here - The one yaml -> yamldumper is probably a blocker. I think the others are more just questions on my part. I'm not sure if there's a rush to get this in -- if so it's probably fine to merge before I get back & can re-review. Otherwise, I would like to bang on it a little more, just to make sure I really understand what the impact is for the LazyLoader 🤔 (I mean, I don't see anything else that's giving me cause for concern - just the fact that we're making the change for the Loader that affects all of salt)
salt/modules/boto_cloudfront.py
Outdated
@@ -263,8 +263,8 @@ def export_distributions(region=None, key=None, keyid=None, profile=None): | |||
# as opposed to being called from execution or state modules | |||
log.trace("Boto client error: {}", exc) | |||
|
|||
dumper = __utils__["yaml.get_dumper"]("IndentedSafeOrderedDumper") | |||
return __utils__["yaml.dump"]( | |||
dumper = __utils__["yamldumper.get_dumper"]("IndentedSafeOrderedDumper") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question do all these need to be changed?
✦2 ❯ ag '"yaml\.' salt
salt/modules/boto_iam.py
1682: return __utils__["yaml.safe_dump"](results, default_flow_style=False, indent=2)
1728: return __utils__["yaml.safe_dump"](results, default_flow_style=False, indent=2)
I'm assuming that this only applies for __utils__
and not __serializers__
- I just went and found a couple of those, specifically in salt/states/file.py - it looks for serialzer_name in serializers where yaml.serialize
is what's called, which doesn't look like the yamldumper 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The yamldumper
only applies to the utils dunder.
They were never using our yamldumper
utils module, they were using the actual yaml
package.
@@ -30,7 +30,7 @@ def configure_loader_modules(setup_vars): | |||
whitelist=[ | |||
"boto3", | |||
"dictdiffer", | |||
"yaml", | |||
"yamldumper", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question if I do git checkout salt/master -- salt/loader/lazy.py
then this doesn't fail 🤔 It only fails if I leave lazy as-is and change this back. Why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because now the loader, correctly, only adds functions defined in the module, not functions imported into the module, unless these are namespaced into the module scope.
@@ -30,7 +30,7 @@ def configure_loader_modules(setup_vars): | |||
whitelist=[ | |||
"boto3", | |||
"dictdiffer", | |||
"yaml", | |||
"yamldumper", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question if I do git checkout salt/master -- salt/loader/lazy.py
then this doesn't fail 🤔 It only fails if I leave lazy as-is and change this back. Why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same answer.
The rush is to get it into 3005. |
To complement, the lazy loader, prior to these changes loaded every function or partial it could get its hands on, namely due to the loader doing a This is the wrong behavior because the loader should only care about functions defined on the module being loaded. If we did On some rare occasions, that is the intended behavior, and thats why the |
However, we were failing to enforce these constraints. |
This is why we should never allowed Which goes against how the LazyLoader was intended to work. |
Fixes saltstack#62186 Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
Fixes saltstack#62190 Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
94e39ea
to
41102c9
Compare
Hi! I'm your friendly PR bot!You might be wondering what I'm doing commenting here on your PR. Yes, as a matter of fact, I am... I'm just here to help us improve the documentation. I can't respond to Okay... so what do you do? I detect modules that are missing docstrings or "CLI Example" on existing docstrings! So what does that have to do with my PR? I noticed that in this PR there are some files changed that have some of these Okay, what are they? Well, my favorite, is that since you were making changes here I'm hoping that If I can, then what? Well, you can either add them to this PR or add them to another PR. Either way is fine! Well... what if I can't, or don't want to? That's also fine! We appreciate all contributions to the Salt Project. If you Whatever approach you decide to take, just drop a comment here letting us know! Detected Issues (click me)Check Known Missing Docstrings...........................................Failed - hook id: invoke - duration: 1.06s - exit code: 1 Thanks again! |
41102c9
to
6a7e599
Compare
The |
…funcs in ``__utils__`` !@#$%@!#@$%!$@#$T Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
6a7e599
to
ab42a89
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we add some documentation about the loaded_base_name
option in the salt/loader/__init__.py
file? We mention it in the changelog, but I think it should be documented in the __init__.py
where that is being added as an additional option.
Can I do it on a follow up PR if @waynew approves this one? I'll do it right after merge. |
@waynew when you get time to re-review this, Pedro will do a follow up PR if you see any more issues. |
loaded_base_name
as a keyword argument, allowing different namespacing the loaded modules.Fixes #62186
Fixes #62190