salt icon indicating copy to clipboard operation
salt copied to clipboard

Jobs cache: keep_jobs not deleting old files

Open LucsT opened this issue 12 years ago • 65 comments

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

LucsT avatar Feb 14 '14 11:02 LucsT

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.

basepi avatar Feb 14 '14 19:02 basepi

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.

LucsT avatar Feb 14 '14 21:02 LucsT

Well, then that's a severe bug that we need to get fixed. Thanks for the report!

basepi avatar Feb 18 '14 16:02 basepi

@LucsT Just to clarify, are the files in question on the master or on the syndic?

cachedout avatar Mar 03 '14 20:03 cachedout

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.

LucsT avatar Mar 04 '14 12:03 LucsT

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.

cachedout avatar Mar 04 '14 16:03 cachedout

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.

LucsT avatar Mar 04 '14 17:03 LucsT

i confirm the same problem

Abukamel avatar Mar 05 '14 07:03 Abukamel

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.

cmeisinger avatar Mar 08 '14 22:03 cmeisinger

@Abukamel and @cmeisinger Could you please let me know what Salt versions you are on, please?

cachedout avatar Mar 10 '14 21:03 cachedout

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 avatar Mar 10 '14 21:03 Abukamel

@Abukamel Was the machine in question also a syndic or just a plain Salt master?

cachedout avatar Mar 10 '14 21:03 cachedout

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 avatar Mar 10 '14 21:03 Abukamel

@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///jid. Be sure to examine the contents of the files, not just the last modified time on the file itself.

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 avatar Mar 10 '14 22:03 cachedout

@cachedout salt-master-2014.1.0-1.el6.noarch . I'll re-enable automatic highstates again and see if it pops back up.

cmeisinger avatar Mar 12 '14 03:03 cmeisinger

@cmeisinger Could you also peek at your cache files and see if the contents contain timestamps older than 24 hours?

cachedout avatar Mar 12 '14 03:03 cachedout

@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]# 

cmeisinger avatar Mar 12 '14 14:03 cmeisinger

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.

basepi avatar Mar 17 '14 23:03 basepi

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.

basepi avatar Mar 24 '14 18:03 basepi

@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 ...

kiorky avatar Apr 06 '14 09:04 kiorky