salt icon indicating copy to clipboard operation
salt copied to clipboard

Comment: Unable to manage file: global name '__salt__' is not defined

Open fmnisme opened this issue 12 years ago • 25 comments

system :windows version:2014.1.1 cmd: state.highstate error:

192.168.1.1:

      ID: D:\\Server-Tools\\Rar.exe
Function: file.managed
  Result: False
 Comment: Unable to manage file: global name '__salt__' is not defined
 Changes:

      ID: D:\\Server-Tools\\addIpsec.exe
Function: file.managed
  Result: True
 Comment: File D:\\Server-Tools\\addIpsec.exe is in the correct state
 Changes:

      ID: C:\\Windows\\System32\\iisset.exe
Function: file.managed
  Result: True
 Comment: File C:\\Windows\\System32\\iisset.exe is in the correct state
 Changes:

      ID: D:\\Script\\salt\\ipsecset.exe
Function: file.managed
  Result: True
 Comment: File D:\\Script\\salt\\ipsecset.exe updated
 Changes:
          ----------
          diff:
              New file

Summary

Succeeded: 3

Failed: 1

Total: 4

fmnisme avatar Apr 17 '14 09:04 fmnisme

I think this may be fixed in the newly-released 2014.1.3 (though I'm not sure the installers for it are up yet). We had a few missing imports from the non-windows file module, and those have been fixed. If you could test when those new installers are available, that would be great.

basepi avatar Apr 18 '14 17:04 basepi

I upgraded to Salt 2014.1.3 AMD64 on my windows minions, and I still got this error while doing a file.recurse. I haven't done extensive testing to determine how often this happens. The directory that I uploaded has several thousand files, and this occurred for the first 10 or so files. The rest were uploaded properly.

dwiden avatar Apr 21 '14 21:04 dwiden

I figured that I would include this as well because the error includes a stack trace. It occurs in about half of my file.recurse/managed states. It does not happen with every file in a file.recurse, only the first few. Then the rest transfer properly.

ID: gnuwin32
    Function: file.recurse
        Name: C:\Program Files (x86)\GnuWin32
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "salt/state.py", line 1378, in call
                File "salt/states/file.py", line 1728, in recurse
                File "salt/modules/file.py", line 2811, in makedirs_perms
                File "salt/modules/file.py", line 2204, in check_perms
            NameError: global name '__salt__' is not defined

dwiden avatar Apr 22 '14 13:04 dwiden

Thanks for the update. Not sure what's going on here, but I pinged @UtahDave on it.

basepi avatar Apr 23 '14 15:04 basepi

This is quite likely fixed by #13194. Any chance of you testing this on a more recent version of develop? I think this issue can probably safely be closed.

cachedout avatar Jun 06 '14 21:06 cachedout

Can anyone verify that this is fixed?

basepi avatar Jun 24 '14 16:06 basepi

@basepi You seem to fix the problem.

fmnisme avatar Jun 25 '14 12:06 fmnisme

All of my file.managed/recurse states now work correctly

dwiden avatar Jun 25 '14 12:06 dwiden

Awesome! Thanks for the verification!

rallytime avatar Jun 25 '14 14:06 rallytime

@basepi salt2014.1.5 this question appear again more than one time on windows

ID: D:\\Server-Tools\\Rar.exe
    Function: file.managed
      Result: False
     Comment: Unable to manage file: global name '__salt__' is not defined
     Changes:

fmnisme avatar Jul 10 '14 07:07 fmnisme

So it was fixed for a time but is popping back up again, @fmnisme? I think that fix was probably in 2014.1.5, but once packages are available I'd love it if you could test on 2014.1.7 which was just released.

basepi avatar Jul 10 '14 20:07 basepi

I'm seeing this error on windows minions on version 2014.1.7

               Salt: 2014.1.7
             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.2
       msgpack-pure: Not Installed
           pycrypto: 2.6
             PyYAML: 3.11
              PyZMQ: 14.1.1
                ZMQ: 4.0.4

The state file looks like:

C:\Jobs\backup-tools:
  file.recurse:
    - source: salt://ServerManagement/backup-tools
    - require:
        - file: 'C:\Jobs'

There are 41 files in there, it usually fails. I have another file.recurse elsewhere with many more files, and it almost always fails. Seems like the more files you have, the more likely it will fail.

ryepup avatar Jul 22 '14 19:07 ryepup

The actual error message:

          ID: C:\Jobs\backup-tools
    Function: file.recurse
      Result: False
     Comment: #### C:\Jobs\backup-tools\7za.exe ####
              Unable to manage file: global name '__salt__' is not defined

              #### C:\Jobs\backup-tools\7zFM.exe ####
              Unable to manage file: global name '__salt__' is not defined

              #### C:\Jobs\backup-tools\DCServce.exe ####
              Unable to manage file: global name '__salt__' is not defined
     Changes:   

The files that have errors change with every run, sometimes more, sometime less.

ryepup avatar Jul 22 '14 19:07 ryepup

I no longer experience this bug.

Linux Master: salt --versions-report Salt: 2014.1.7 Python: 2.7.3 (default, Feb 27 2014, 19:58:35) Jinja2: 2.7.3 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

Windows 7 x86-64 Minion: Salt: 2014.1.7 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.2 msgpack-pure: Not Installed pycrypto: 2.6 PyYAML: 3.11 PyZMQ: 14.1.1 ZMQ: 4.0.4

dwiden avatar Aug 06 '14 13:08 dwiden

Thanks for the report, @dwiden!

I'm going to do a little more testing as well.

@ryepup are you still seeing this issue?

UtahDave avatar Aug 06 '14 16:08 UtahDave

@UtahDave Yes, I can still recreate this error.

Seems to happen more often when there are a lot of files to move, but it's intermittant. I can have it work on minion A, then fail on the minion B. My minions have the same versions as @dwiden's.

My best guess is a race condition somewhere; it seems to consisently work on my A minion, and consistently fail on my B minion. There are both virtual machines, but B is a Win2012R2 production machine on vmware served from a NAS, and A is a Win7 dev machine on kvm and local disks. B is probably having to work harder than A to get anything done, with higher latency on just about every resource.

ryepup avatar Aug 06 '14 16:08 ryepup

@ryepup Ah, that info helps a lot. Thank you.

UtahDave avatar Aug 06 '14 21:08 UtahDave

Both of my Win 7 VMs are in VirtualBox. One of them has 4 GB of RAM and 2 processors, another has 2 GB of RAM with 1 processor, both set to 100% execution cap. My file.managed/recurse states have about a thousand files in total (all pretty small, < 10K). I ran them both at the same time and there were no failures.

I'm running the VMs on a macbook pro 10.9.4 2.3 GHz i7, with 16 GB of RAM. Hope this helps

dwiden avatar Aug 08 '14 13:08 dwiden

I had this problem today against an older physical machine running 2014.1.4.

I upgraded it to 2014.1.10, and haven't seen it on that machine again; either I'm getting very lucky, or a fix slipped in somewhere.

I'll test some more machines on 2014.1.10

ryepup avatar Aug 15 '14 21:08 ryepup

I can't recreate this issue with 2014.1.10.

I updated the VM that consistently had this error to 2014.1.10, and it's working great.

ryepup avatar Aug 18 '14 13:08 ryepup