salt icon indicating copy to clipboard operation
salt copied to clipboard

CPU usage on windows XP

Open DamianZaremba opened this issue 13 years ago • 7 comments

Hi,

I've noticed excessive CPU usage by salt-minion on XP using the install @ http://saltstack.org/static/downloads/Salt-Minion-0.11.1-Setup-amd64.exe.

The usage spikes from none to 100% constantly with no jobs running windows_cpu_usage

Nothing else is running on the pc and task manager shows the usage is from the salt-minion process.

Using the same install on a windows 7 machine doesn't cause any cpu usage when the minion is idle.

Not 100% sure how to debug this further, or if it's salt or this build of salt's issue.

DamianZaremba avatar Jan 08 '13 15:01 DamianZaremba

Thanks for the report! I haven't tested on XP so it's great to have some data.

I built the installer on Windows Server 2008 and Windows 7, both 64 bit using all 64 bit libraries. Is your XP machine 32 bit?

I think I'm going to build an installer on WinXP using only 32bit libraries and see if that works better. What do you think?

UtahDave avatar Jan 08 '13 15:01 UtahDave

That was a 64bit box, was going to try 32bit but the install was amd64 - didn't see if it would install, just assumed it wouldn't.

A 32 bit install for XP would be very useful for me at least, can probably do some testing on 32bit either this week or next if needed.

DamianZaremba avatar Jan 08 '13 21:01 DamianZaremba

@DamianZaremba, can you try the new 32bit installer found here: http://docs.saltstack.org/en/latest/topics/installation/windows.html

Be sure to uninstall your previous salt-minion install and delete c:\salt before installing this one.

Once, when testing, I did have to manually start the service after the installation finished.

UtahDave avatar Jan 28 '13 20:01 UtahDave

I'm having this same issue. 32-bit Windows XP the minion runs at 100% CPU, and also doesn't respond to commands.

If I run it from the command line it works fine. Also, if I change the Log On from Local System to an actual user account it also runs fine.

nigelsim avatar Feb 09 '13 23:02 nigelsim

Putting in some extra debug code I get:

No module named pwd File "c:\salt\salt-0.12.1.win32\salt-0.12.1-py2.7.egg\salt__init__.py", line 195, in start self.minion.tune_in() File "salt/minion.py", line 592, in tune_in File "getpass.py", line 157, in getuser

This seems to be because the getpass.getuser method (Python builtin) does: for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'): user = os.environ.get(name) if user: return user

# If this fails, the exception will "explain" why
import pwd
return pwd.getpwuid(os.getuid())[0]

When we're running as the system user, at least on WinXP, so I guess the best solution would be to create a custom implementation of get_user that use win32api.GetUserName() on window if it is possible to include the pywin32 package? (actually, it seems to be included now?)

Initial tests show this will work, but I'm not sure out the other methods that call getname() will react when it get SYSTEM as the username?

nigelsim avatar Feb 10 '13 02:02 nigelsim

Just to confirm what @nigelsim discovered: a quick hack of putting try/except around the log.info call in tune_in was enough to get salt working smoothly on my Server 2003 system.

--- a/salt/minion.py
+++ b/salt/minion.py
@@ -644,12 +644,15 @@ class Minion(object):
         '''
         Lock onto the publisher. This is the main event loop for the minion
         '''
-        log.info(
-            '{0} is starting as user \'{1}\''.format(
-                self.__class__.__name__,
-                getpass.getuser()
+        try:
+            log.info(
+                '{0} is starting as user \'{1}\''.format(
+                    self.__class__.__name__,
+                    getpass.getuser()
+                )
             )
-        )
+        except:
+            pass
         log.debug('Minion "{0}" trying to tune in'.format(self.opts['id']))
         self.context = zmq.Context()

I didn't say it was pretty :)

djs52 avatar Feb 18 '13 12:02 djs52

I believe this has been fixed by the referenced commits above. I'll have a new Windows Salt installer up tomorrow. Please feel free to reopen this issue if you still are encountering this problem.

Thanks!

UtahDave avatar Feb 21 '13 01:02 UtahDave