From 7ccd232e4d47778b2ede7a7f318baa41c39d6a0c Mon Sep 17 00:00:00 2001 From: Mike Place Date: Thu, 26 May 2016 11:14:56 -0600 Subject: [PATCH 14/14] Fix crashing Maintenence process The first time through the loop we deleted the dir and then stack traced the second time through the loop if we hit the other conditional. Resolves #33544 --- salt/returners/local_cache.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/salt/returners/local_cache.py b/salt/returners/local_cache.py index 17d5066b218f..8bd833b5f99f 100644 --- a/salt/returners/local_cache.py +++ b/salt/returners/local_cache.py @@ -407,14 +407,14 @@ def clean_old_jobs(): for final in t_path_dirs: f_path = os.path.join(t_path, final) jid_file = os.path.join(f_path, 'jid') - if not os.path.isfile(jid_file): + if not os.path.isfile(jid_file) and os.path.exists(t_path): # No jid file means corrupted cache entry, scrub it # by removing the entire t_path directory shutil.rmtree(t_path) - else: + elif os.path.isfile(jid_file): jid_ctime = os.stat(jid_file).st_ctime hours_difference = (cur - jid_ctime) / 3600.0 - if hours_difference > __opts__['keep_jobs']: + if hours_difference > __opts__['keep_jobs'] and os.path.exists(t_path): # Remove the entire t_path from the original JID dir shutil.rmtree(t_path) -- 2.8.3