Jobs cache: keep_jobs not deleting old files
Hello,
Problem : Jobs call with cmd_async let millions of files in directory /var/cache/salt/master/jobs/ Files seems to be never deleted. Even if I set a strict settings 'keep_jobs: 1' Problem is more about number of files(inodes) than disk space for me.
I have a syndic with about 200 minions.
I see the number of files growth with X*Y where X:number of minions in this syndic Y: jobs launched
Versions (minion, syndic, master) are: Salt: 0.17.5 Python: 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) Jinja2: 2.5.5 M2Crypto: 0.20.1 msgpack-python: 0.1.10 msgpack-pure: Not Installed pycrypto: 2.1.0 PyYAML: 3.09 PyZMQ: 13.1.0 ZMQ: 3.2.3
Not very familar with erlang, only solution I found to avoid problem is to manually erase file jobs. Tell me if anything else is welcome.
Lucas
So just to verify that we're on the same page, keep_jobs: 1 means that the master will keep jobs for one hour. Are you seeing files in the cache older than one hour? There may be a bug/edge case in the cleanup routines that we need to fix.
If you're just generating too many inodes per hour (unlikely, but possible) then I would recommend looking into an external job cache.
Yes I mean my jobs cache files stay forever. So cache older than 'keep_jobs' hours is not deleted. I tested default (I read in doc is 24h), 2h , 1h.
Well, then that's a severe bug that we need to get fixed. Thanks for the report!
@LucsT Just to clarify, are the files in question on the master or on the syndic?
Both
I see the problem on syndic first. Because partition is more tiny. Now I erase periodically the cache with cron. Even in my Master of master.
I remember the Inodes growth too on the Master of master.
Any complement, I launch command using cmd_async. Then I take the return with get_cli_return. Maybe the cache cleaning doesn't work only with that kind of call.
OK. I can't replicate this all on v2014.1. I will try again on v17.5.
The cache cleaner shouldn't have anything to do with the type of call. It runs as a part of the main master event loop and simply cleans up job directories older than a certain time.
If you're handy with Python, you could start putting some debug statements in the _clear_old_jobs() function in master.py and see if the problem becomes obvious.
Ok, for info on cache cleaner.
I have no time to test it in next few days. Maybe at end of week; Be back here to post interresting returns if I have.
i confirm the same problem
This issue crashed my Saltstack machine today as it ran the VM out of inodes, all of which were utilized in /var/cache/salt/master/jobs/. I had to stop salt, manually delete the cache directory and then restart salt to get a functioning machine again.
Once I did that and restarted salt, it appeared to keep up as it should.
@Abukamel and @cmeisinger Could you please let me know what Salt versions you are on, please?
2014
On 3/10/14, Mike Place [email protected] wrote:
@Abukamel and @cmeisinger Could you please let me know what Salt versions you are on, please?
Reply to this email directly or view it on GitHub: https://github.com/saltstack/salt/issues/10443#issuecomment-37235484
Regards, Ahmed Kamel Linux/Hosting Systems Engineer
@Abukamel Was the machine in question also a syndic or just a plain Salt master?
just a master
On 3/10/14, Mike Place [email protected] wrote:
@Abukamel Was the machine in question also a syndic or just a plain Salt master?
Reply to this email directly or view it on GitHub: https://github.com/saltstack/salt/issues/10443#issuecomment-37237329
Regards, Ahmed Kamel Linux/Hosting Systems Engineer
@Abukamel or @LucsT. Could either of you confirm that if you examine the contents of JID files that they contain a timestamp older than 24 hours? The jid files should be in /var/cache/salt/master/jobs/
I'm trying to determine if we're just simply creating more job files than before or if we aren't cleaning up old ones. I continue to see JID files cleaned up correctly in my testing environment.
@cachedout salt-master-2014.1.0-1.el6.noarch . I'll re-enable automatic highstates again and see if it pops back up.
@cmeisinger Could you also peek at your cache files and see if the contents contain timestamps older than 24 hours?
@cachedout
[root@saltstack 56ff378bf53427bf00903c1759d811]# date; ls -alh jid; cat jid
Wed Mar 12 09:47:53 CDT 2014
-rw-r--r-- 1 root root 20 Mar 12 08:15 jid
20140312081503316474[root@saltstack 56ff378bf53427bf00903c1759d811]#
So I did some code-diving and the comparison we were using for this cleanup routine was fairly naive and error-prone. I have rewritten it here: https://github.com/saltstack/salt/pull/11308
I also added some additional failsafes to hopefully make sure corrupted entries don't stick around. I've done some testing and it seems to be working flawlessly for me. Once that pull request is merged, if someone could test on develop that would be fantastic.
This fix is in 2014.1.1. I'm going to close this issue, but am happy to reopen it if someone sees this behavior pop up again.
@thatch45 @basepi which is the fix ? I dont know what, but something is rescanning my whole jobs dir very often making the whole system unusable and the only workaround i ve found is to wipe the cache for the scan to work ...