Commit 24fc781f authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Don't always remove queue lock when queue is purged

The lock should only be removed if ganeti-noded is going to quit.
Otherwise it needs to be kept to prevent another process from creating
it again while we're still holding the (removed) lock. This is due to
POSIX filesystem semantics.

Reviewed-by: iustinp
parent 76ab5558
......@@ -69,6 +69,19 @@ def _CleanDirectory(path, exclude=[]):
utils.RemoveFile(full_name)
def _JobQueuePurge(keep_lock):
"""Removes job queue files and archived jobs
"""
if keep_lock:
exclude = [constants.JOB_QUEUE_LOCK_FILE]
else:
exclude = []
_CleanDirectory(constants.QUEUE_DIR, exclude=exclude)
_CleanDirectory(constants.JOB_QUEUE_ARCHIVE_DIR)
def _GetMasterInfo():
"""Return the master ip and netdev.
......@@ -192,7 +205,8 @@ def LeaveCluster():
"""
_CleanDirectory(constants.DATA_DIR)
JobQueuePurge()
# The lock can be removed because we're going to quit anyway.
_JobQueuePurge(keep_lock=False)
try:
priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS)
......@@ -1698,8 +1712,9 @@ def JobQueuePurge():
"""Removes job queue files and archived jobs
"""
_CleanDirectory(constants.QUEUE_DIR)
_CleanDirectory(constants.JOB_QUEUE_ARCHIVE_DIR)
# The lock must not be removed, otherwise another process could create
# it again.
return _JobQueuePurge(keep_lock=True)
def JobQueueRename(old, new):
......
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