Commit 1bc59f76 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Never remove job queue lock in node daemon

Otherwise, corruption could occur in some corner cases. E.g. when
LeaveNode is running in a child and is in the process of removing
queue files, the main process gets killed, started again and gets
a request to update the queue. This is rather extreme corner case,
but we should opt for safety.

Reviewed-by: iustinp
parent 36205981
......@@ -69,16 +69,11 @@ def _CleanDirectory(path, exclude=[]):
utils.RemoveFile(full_name)
def _JobQueuePurge(keep_lock):
def JobQueuePurge():
"""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.QUEUE_DIR, exclude=[constants.JOB_QUEUE_LOCK_FILE])
_CleanDirectory(constants.JOB_QUEUE_ARCHIVE_DIR)
......@@ -211,9 +206,7 @@ def LeaveCluster():
"""
_CleanDirectory(constants.DATA_DIR)
# The lock can be removed because we're going to quit anyway.
_JobQueuePurge(keep_lock=False)
JobQueuePurge()
try:
priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS)
......@@ -1717,15 +1710,6 @@ def JobQueueUpdate(file_name, content):
return True
def JobQueuePurge():
"""Removes job queue files and archived jobs
"""
# The lock must not be removed, otherwise another process could create
# it again.
return _JobQueuePurge(keep_lock=True)
def JobQueueRename(old, new):
"""Renames a job queue file.
......
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