-
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
loader: support extra modules in sys.path #53167
Conversation
edfada4
to
d844c9c
Compare
There's a test failure happening https://jenkinsci.saltstack.com/job/pr-kitchen-windows2016-py3/job/PR-53167/3/testReport/junit/integration.states.test_file/FileTest/test_file_managed_onchanges/ - I'm not sure if that's related to this PR or not Also looks like there's a merge conflict 😛 Otherwise, I think this is looking good. |
How this PR relates to #52001? Does it extend or replace it? |
@max-arnold I think that is a replacement of this one. Maybe is a good idea to add a commit here to revert the other code. |
@max-arnold I added the revert commit here @waynew I rebased the code. Also I do not see the windows fail related with the code. Lets see if is still present after the rebase. |
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.
I think this is ready to go, assuming tests pass after the rebase 😛
5d9f32a
to
3133538
Compare
@max-arnold Not sure about salt-ssh (#53666), but this fix #52136. I will not be able to test #53666 for some time (out from the office for a while) |
@aplanas I'm not very familiar with the loader internals, but it seems like other module types also import In other words, if there is a bug in Below is a list of functions in
What do you think about this idea? |
@max-arnold you can be right. I updated the LazyLoader constructors where there is an explicit call to make For example, in return LazyLoader(
_module_dirs(opts, 'auth'),
opts,
tag='auth',
whitelist=whitelist,
pack={'__salt__': minion_mods(opts)},
) I would expect that only Can be that there is a different mechanism where Can we do that later? |
We can definitely do this later, and it looks like there will be enough time (a few months?) before the |
2198b99
to
dc53fbb
Compare
windows errors are related to utils.pycrypto: AttributeError: 'module' object has no attribute 'crypt' |
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.
I think this looks good, but we have some issues going on with our Windows test suite that we need to figure out. As you point out, I don't think they're related to the changes in this PR.
We had some timeouts happening, something going wonky with the infrastructure(?) I've restarted the Windows tests - assuming they pass this should be good to merge in 👍 |
Hm. I'm a bit confused. I merged the latest master into this PR and yet there's still an issue with the crypt thing? I don't have time to look at this today but I'll stick it on my list. |
I rebased, let me check the results. |
Yep. Ignore the lint, is not related with my code: ************* Module salt.returners.django_return Your code has been rated at 10.00/10 |
f936a07
to
22a6ee0
Compare
88115bb
to
3cf0684
Compare
@aplanas looks like still some lint complaints 😕 I'm not sure if a rebase on master will sort this out, but if you're using pre-commit then it should also run lint checks. I feel like I ran into some weird issues with this particular kind of import (importing from collections, also abc's). I've set a If you have issues, please ping me in #salt on IRC or in the community Slack. |
The LazyLoader class populate the sys.path array to add the path that contains the Python module that will be executed. If before this point sys.path gets extended (like when globally the extmods utils directory in added in some places, like after a sync) the code can find all the dependencies. This patch adds a new parameter to the LazyLoader class, extra_module_dirs, that will populate locally the sys.path before executing the the module. This can be used to guarantee that in utils (and other modules) will be available to the modules and states in any circumstances and Python process.
Because we are mangling with importlib, we can find from time to time an invalidation issue with sys.path_importer_cache, that requires the removal of FileFinder that remain None for the extra_module_dirs
no failing test, re-review? |
What does this PR do?
The LazyLoader class populate the sys.path array to add the path
that contains the Python module that will be executed. If before
this point sys.path gets extended (like when globally the extmods
utils directory in added in some places, like after a sync) the
code can find all the dependencies.
This patch adds a new parameter to the LazyLoader class,
extra_module_dirs, that will populate locally the sys.path before
executing the the module.
This can be used to guarantee that in utils (and other modules) will be
available to the modules and states in any circumstances and Python
process.
Tests written?
Yes