From 1bc59f761a87e8efebff9e5c53ed00b36327fe06 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Tue, 9 Sep 2008 12:47:16 +0000 Subject: [PATCH] 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 --- lib/backend.py | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index ca86245..cb8de54 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -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. -- 1.7.10.4