On Windows file state throws exception in check_perms: global name '__salt__' is not defined
Hi,
when i try to use a file.managed or file.recurse state, very often the following exception will be thrown:
An exception occurred in this state: Traceback (most recent call last):
File "salt/state.py", line 1316, in call
File "salt/states/file.py", line 1157, in managed
File "salt/modules/file.py", line 2095, in manage_file
File "salt/modules/file.py", line 2234, in makedirs
File "salt/modules/file.py", line 2193, in mkdir
File "salt/modules/file.py", line 2269, in makedirs_perms
File "salt/modules/file.py", line 1690, in check_perms
NameError: global name '__salt__' is not defined
Sometimes it runs without a exception but mostly not.
Minion (Windows Server 2008 R2):
Salt: 0.17.5-52-g2d4772c
Python: 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]
Jinja2: 2.7.1
M2Crypto: 0.21.1
msgpack-python: 0.4.0
msgpack-pure: Not Installed
pycrypto: 2.6
PyYAML: 3.10
PyZMQ: 13.1.0
ZMQ: 3.2.2
Master (Ubuntu 12.04 LTS AMD64):
Salt: 0.17.5
Python: 2.7.3 (default, Sep 26 2013, 20:03:06)
Jinja2: 2.6
M2Crypto: 0.21.1
msgpack-python: 0.1.10
msgpack-pure: Not Installed
pycrypto: 2.4.1
PyYAML: 3.10
PyZMQ: 13.0.0
ZMQ: 3.2.2
Thanks for the report!
@UtahDave ping
Running into this as well. Trying to run file.recurse on a directory and this is making it impossible. Is there a version that doesn't have this issue? I'm trying to evaluate salt for work and this is completely blocking me.
@todesregen @gtmacdonald Can you test this on 2014.1.0? I believe this has been fixed.
Hi,
tested with 2014.1.0 and it is still not working. the same execption occures:
2014-03-05 08:26:41,761 [salt.fileclient ][DEBUG ] Fetching file from saltenv 'base', ** attempting ** 'salt://win/process-explorer/procexp.exe'
2014-03-05 08:26:42,026 [salt.fileclient ][INFO ] Fetching file from saltenv 'base', ** done ** 'win/process-explorer/procexp.exe'
2014-03-05 08:26:42,042 [salt.loaded.int.states.file][DEBUG ] Traceback (most recent call last):
File "salt/states/file.py", line 1293, in managed
File "salt/modules/file.py", line 2625, in manage_file
File "salt/modules/file.py", line 2764, in makedirs
File "salt/modules/file.py", line 2723, in mkdir
File "salt/modules/file.py", line 2799, in makedirs_perms
File "salt/modules/file.py", line 2196, in check_perms
NameError: global name '__salt__' is not defined
2014-03-05 08:26:42,042 [salt.state ][ERROR ] Unable to manage file: global name '__salt__' is not defined
2014-03-05 08:26:42,042 [salt.state ][INFO ] Completed state [C:\process-explorer\procexp.exe] at time 08:26:42.042000
and what may be also interresting for you, the postgres module also throws an exception:
2014-03-05 08:26:41,902 [salt.loader ][DEBUG ] Failed to import module postgres, this is most likely NOT a problem:
Traceback (most recent call last):
File "salt/loader.py", line 700, in gen_functions
File "salt/modules/postgres.py", line 29, in <module>
ImportError: No module named csv
It looks a litte bit messy in the log file :P
Looks like it's fixed! Thank you very much!!!
I've been running a large directory sync for 15 minutes now without the exception where it was dying immediately before. I get the postgres stacktrace too but it doesn't seem to matter.
@todesregen Did you update both server and minion? That may be something to try.
Yes, I updated both. I did not try a file.recurse but the file.managed still raises the above exception sometimes.
Oh ok, I haven't tried file.managed yet. I'll let you know when I do.
@UtahDave @todesregen I take it back, it is happening with file.recurse as well. :( Seems to be intermittent.
OK, I'll do some testing on this today. Thanks for the info!
@UtahDave Were you able to reproduce the issue? If not I can try and take a look.
I haven't. On Mar 6, 2014 2:43 PM, "Greg MacDonald" [email protected] wrote:
@UtahDave https://github.com/UtahDave Were you able to reproduce the issue? If not I can try and take a look.
Reply to this email directly or view it on GitHubhttps://github.com/saltstack/salt/issues/10773#issuecomment-36940895 .
Since you can't reproduce, it might be that I changed the username and group of the file server root to a user account in order to setup samba. I'll try switching it back to root and see...
Ah, sorry for the unclear answer. I meant I haven't had time to try to reproduce it. I've been slammed with some deadlines On Mar 7, 2014 12:38 PM, "Greg MacDonald" [email protected] wrote:
Since you can't reproduce, it might be that I changed the username and group of the file server root to a user account in order to setup samba.
Reply to this email directly or view it on GitHubhttps://github.com/saltstack/salt/issues/10773#issuecomment-37059667 .
I understand, I'm in the same boat. :)
Changing the username and group back to root seems to have removed the stack trace, but I still got this message on the first run:
Unable to manage file: global name 'salt' is not defined
I didn't see it on the second run, and both runs completed without throwing exceptions. And it looks like the directory was successfully copied down to the minion.
So I'm not blocked anymore but it looks like there still might be something going on.
I can confirm this intermittent bug. Here is a pastebin of my output: http://pastebin.com/iWGRR3YX
This seems to be affecting about 20% of my windows servers on each salt '*' state.highstate run. Since it is intermittent I thought it (a long shot) might be related to the number of worker threads on the master. I reduced the workers from 20 to 2, but it did not seem to help solve the problem, there were still many failures.
It makes it nearly impossible to control my environment when 20% of my windows machines fail to take the proper state. This is a pretty major problem for my company.
@shealutton I'm sorry this is causing you difficulties. I'm traveling for work this week. I'll get working on this first thing Monday.
Also, bumping this to high severity
Thanks UtahDave, much appreciated.
@UtahDave this could be in the loader, like #11235. However, the issue he's having over there is much more consistent and seemingly reproduceable. Since states should be executed in the same order every time, I doubt they're the same issue, but could be related.