Commit f78346f5 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Clean job queue directories when leaving cluster

Old job files shouldn't be left on nodes removed from a cluster.

Reviewed-by: iustinp
parent c54784d9
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment