salt icon indicating copy to clipboard operation
salt copied to clipboard

Minion sometimes stops logging after logrotate

Open syphernl opened this issue 12 years ago • 29 comments

It appears that after a logrotate has occurred the minion stops logging:

root@shared01:/var/log/salt# ls -alh
total 360K
drwxr-xr-x  2 root root   4,0K jun 15 06:42 .
drwxrwxr-x 14 root syslog 4,0K jun 19 06:37 ..
-rw-------  1 root root      0 jun 15 06:42 minion
-rw-------  1 root root    75K jun 11 09:58 minion.1.gz
-rw-------  1 root root    13K jun 10 10:47 minion.2.gz
-rw-------  1 root root   2,4K jun  5 16:01 minion.3.gz
-rw-------  1 root root    43K mei 26 10:58 minion.4.gz
-rw-------  1 root root    133 mei 14 01:40 minion.5.gz
-rw-------  1 root root    72K mei  7 10:05 minion.6.gz
-rw-------  1 root root   134K mei  2 14:50 minion.7.gz

I have checked another minion and there it is logging properly though.

Logging has not explicitly been configured in the minion configuration so it uses the default values.

Version report:

           Salt: 2014.1.5
         Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
         Jinja2: 2.7.2
       M2Crypto: 0.21.1
 msgpack-python: 0.3.0
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
         PyYAML: 3.10
          PyZMQ: 14.0.1
            ZMQ: 4.0.4

syphernl avatar Jun 19 '14 09:06 syphernl

Thanks for the report, we'll investigate this. Keep us posted if you can find any way to consistently reproduce this.

@s0undt3ch any idea what might be going on here?

basepi avatar Jun 19 '14 20:06 basepi

If python logging can't detect that we lost the current file.... it should at least error out...

I'll see what's going on here...

s0undt3ch avatar Jun 20 '14 00:06 s0undt3ch

I can confirm I'm experiencing this problem as well with this logrotate configuration:

$ cat /etc/logrotate.d/salt-minion /var/log/salt/minion { missingok notifempty rotate 7 daily sharedscripts delaycompress postrotate /sbin/service salt-minion condrestart endscript }

wongster80 avatar Jun 24 '14 01:06 wongster80

Do we have a status on this?

wongster80 avatar Oct 03 '14 17:10 wongster80

That would be @s0undt3ch -- did you ever have a chance to look into this?

basepi avatar Oct 06 '14 20:10 basepi

Still haven't had time to investigate this

s0undt3ch avatar Oct 28 '14 19:10 s0undt3ch

Seeing the same sort of thing here.

       Salt: 2014.7.0
     Python: 2.6.9 (unknown, Sep 13 2014, 00:25:11)
     Jinja2: 2.7.2
   M2Crypto: 0.20.2

msgpack-python: 0.1.13 msgpack-pure: Not Installed pycrypto: 2.6.1 libnacl: Not Installed PyYAML: 3.10 ioflo: Not Installed PyZMQ: 14.3.1 RAET: Not Installed ZMQ: 3.2.4 Mako: Not Installed

Also, I'm also seeing the minion getting stuck in state.sls after log rotation.

The function "state.sls" is running as PID 26980 and was started at 2014, Nov 25 18:11:39.264444 with jid 20141125181139264444

Restarting the minion seems to fix it until the next log rotation.

shawnbutts avatar Nov 25 '14 18:11 shawnbutts

I think I am experiencing this one as well.

Ubuntu 12.04 and Ubuntu 14.04

$ salt-minion --versions
 Jinja2: 2.7.2
 M2Crypto: 0.21.1
 msgpack-python: 0.3.0
 msgpack-pure: Not Installed
 pycrypto: 2.6.1
 libnacl: Not Installed
 PyYAML: 3.10
 ioflo: Not Installed

calve avatar Dec 18 '14 10:12 calve

Moreover, on my systems, minions fails to respond to master after that rotation occured.

calve avatar Dec 18 '14 10:12 calve

For now, I added a postrotate script to restart the service after a rotation

/var/log/salt/minion {
        weekly
        missingok
        rotate 7
        compress
        notifempty
        postrotate
            sudo service salt-minion restart
        endscript
}

calve avatar Dec 18 '14 11:12 calve

I'm also seeing minions getting wedged after logrotation. It doesn't happen on all of the hosts, but on many. I ended up updating the logrotate routine to bounce the minion too

Centos6, salt-minion-2014.1.10-4.el5

deeno35 avatar Dec 23 '14 21:12 deeno35

Is there a pattern? Or is it different machines each time?

basepi avatar Jan 05 '15 19:01 basepi

For me there wasn't a pattern - different machines on different days. I didn't track it specifically since postrotate minion restart "fixed" it

deeno35 avatar Jan 05 '15 19:01 deeno35

My pattern was : every thursday morning, I had down minions. After investigation, it matched the weekly option of my /etc/logrotate.d/salt- common which, I guess, came with the Ubuntu package.

Le lundi 5 janvier 2015, 11:57:55 David Nguyen a écrit :

For me there wasn't a pattern - different machines on different days. I didn't track it specifically since postrotate minion restart "fixed" it


Reply to this email directly or view it on GitHub: https://github.com/saltstack/salt/issues/13558#issuecomment-68767249

calve avatar Jan 05 '15 21:01 calve

@s0undt3ch You need to use the WatchedFileHandler class if you expect external software to rotate your logs.

thedrow avatar Jan 11 '15 12:01 thedrow

Any update on this issue ? Here is my exact pattern :

  • minions runnings
  • logrotate rotates /var/log/salt/minion
  • minions keep responding to salt-call manage.up
  • let pass a few days (or any arbitrary amount of time) doing nothing with salt
  • run a command from the master salt * test.ping
  • minions crashes (sometimes not immediately, but after a few commands)
  • call admin to ssh into minions and resurect them

Today, I noticed that all minions crashed, but I didnot targetted them all. I mean i runned salt 'G@env:dev' test.ping and all minions crashed (I expected just those matching G@env:dev to crash)

calve avatar Mar 05 '15 14:03 calve

I think salt minion should rotate its own logs instead of outsourcing its job to logrotate.

crocket avatar Aug 09 '15 06:08 crocket

@thedrow we do use WatchedFileHandler for Py >= 2.6 @crocket sysadmins are used to having logorate do the logs rotation, a feature required to specify rotation could be opened though and the conversation about it could be continued there.

s0undt3ch avatar Aug 10 '15 14:08 s0undt3ch

@s0undt3ch In that case I have no idea what could be wrong. What happens if you just remove the log file using rm? Does salt still stop logging?

thedrow avatar Aug 10 '15 14:08 thedrow

Guess we need to add a test case to try exactly that....

s0undt3ch avatar Aug 30 '15 11:08 s0undt3ch