Skip to content

Make raw imports from _utils work - #46841

Closed
mephi42 wants to merge 1 commit into
saltstack:developfrom
mephi42:make-raw-imports-from-utils-work
Closed

Make raw imports from _utils work#46841
mephi42 wants to merge 1 commit into
saltstack:developfrom
mephi42:make-raw-imports-from-utils-work

Conversation

@mephi42

@mephi42 mephi42 commented Apr 3, 2018

Copy link
Copy Markdown
Contributor

This is a quick hack to make it work with salt-ssh.
It would be great if anyone could outline the proper solution, since I got lost in module loading logic.

What issues does this PR fix or reference?

#32500

Previous Behavior

Importing _utils module resulted in ImportError.

New Behavior

Importing _utils module works as described in https://docs.saltstack.com/en/latest/topics/utils/index.html

Tests written?

No

Commits signed with GPG?

Yes

@mephi42
mephi42 force-pushed the make-raw-imports-from-utils-work branch from 357eddb to 1c26f09 Compare April 4, 2018 09:28
@mephi42
mephi42 requested a review from a team as a code owner April 4, 2018 09:28

@terminalmage terminalmage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would not be a good idea, it would add utils functions to both __salt__ and __states__.

Can you show an example of what you're trying to do, what you expect to happen, and what is happening instead? Your most recent comment in the linked issue doesn't really offer much information.

@rallytime rallytime added the pending-discussion The issue or pull request needs more discussion before it can be closed or merged label Apr 4, 2018
@mephi42

mephi42 commented Apr 4, 2018

Copy link
Copy Markdown
Contributor Author

I'm trying to make the following example from the doc work:

_utils/mymodule.py:

class Foo(object):
    def bar(self):
        return 'baz'

_modules/awesome.py:

import mymodule
def observe_the_awesomeness():
    foo = mymodule.Foo()
    return foo.bar()

In v2017.7.3 it fails with an ImportError.

@terminalmage

Copy link
Copy Markdown
Contributor

OK, I'm not familiar with this functionality, I will investigate.

@mephi42

mephi42 commented Apr 6, 2018

Copy link
Copy Markdown
Contributor Author

I see now what you meant in your comment:

[ERROR   ] Module/package collision: '<redacted>/lib/python2.7/site-packages/salt/utils/docker' and '<redacted>/lib/python2.7/site-packages/salt/states/docker.py'
[ERROR   ] Module/package collision: '<redacted>/lib/python2.7/site-packages/salt/utils/pkg' and '<redacted>/lib/python2.7/site-packages/salt/states/pkg.py'

I did not use those states when I tested the patch, so it looked okay.

@cachedout

Copy link
Copy Markdown
Contributor

We definitely don't want to merge this. I'm going to close this but we can discuss a path forward in #32500.

@cachedout cachedout closed this Apr 12, 2018
@mephi42

mephi42 commented Apr 18, 2018

Copy link
Copy Markdown
Contributor Author

No problem, let's discuss the possible alternatives there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-discussion The issue or pull request needs more discussion before it can be closed or merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants