diff --git a/lib/backend.py b/lib/backend.py index 7e9f2d2c85209926b76c71eb28c96eb573239330..8a5575dd500d56f2c0b675de814e6dbf7e86347c 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: