From f78346f5bfa271863fe3d115d932796257616d8a Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 6 Aug 2008 11:27:41 +0000 Subject: [PATCH] Clean job queue directories when leaving cluster Old job files shouldn't be left on nodes removed from a cluster. Reviewed-by: iustinp --- lib/backend.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index 7e9f2d2c8..8a5575dd5 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -169,12 +169,20 @@ def LeaveCluster(): """Cleans up the current node and prepares it to be removed from the cluster. """ - if os.path.isdir(constants.DATA_DIR): - for rel_name in utils.ListVisibleFiles(constants.DATA_DIR): - full_name = os.path.join(constants.DATA_DIR, rel_name) + def _CleanDirectory(path): + if not os.path.isdir(path): + return + for rel_name in utils.ListVisibleFiles(path): + full_name = os.path.join(path, rel_name) if os.path.isfile(full_name) and not os.path.islink(full_name): utils.RemoveFile(full_name) + _CleanDirectory(constants.DATA_DIR) + + # Remove job queue files and archived jobs + _CleanDirectory(constants.QUEUE_DIR) + _CleanDirectory(constants.JOB_QUEUE_ARCHIVE_DIR) + try: priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS) except errors.OpExecError: -- GitLab