Blob Blame History Raw
From f2bc403879234aaaeeb61e1dca1affe18192cfa1 Mon Sep 17 00:00:00 2001
From: Eugene Kirpichov <ekirpichov@gmail.com>
Date: Sat, 21 Jul 2012 23:17:55 +0000
Subject: [PATCH] Fix wrong regex in cleanup_file_locks.

The sentinel filename actually has form hostname-threadid.pid,
not hostname.threadid-pid.

Launchpad bug 1018586.

Update: Add Eugene to Authors for stable/essex.

Change-Id: I09c01e0e63ee704b1485c196dc0b396ee03b2e5c
(cherry picked from commit 974417b75f5f839ce4daaf080147ad154d727f10)
---
 Authors                  |    1 +
 nova/tests/test_utils.py |    2 +-
 nova/utils.py            |    2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Authors b/Authors
index 591c449..a903742 100644
--- a/Authors
+++ b/Authors
@@ -62,6 +62,7 @@ Eldar Nugaev <reldan@oscloud.ru>
 Eoghan Glynn <eglynn@redhat.com>
 Eric Day <eday@oddments.org>
 Eric Windisch <eric@cloudscaling.com>
+Eugene Kirpichov <ekirpichov@gmail.com>
 Evan Callicoat <diopter@gmail.com>
 Ewan Mellor <ewan.mellor@citrix.com>
 Fran├žois Charlier <francois.charlier@enovance.com>
diff --git a/nova/tests/test_utils.py b/nova/tests/test_utils.py
index 501ff91..5babf4c 100644
--- a/nova/tests/test_utils.py
+++ b/nova/tests/test_utils.py
@@ -908,7 +908,7 @@ class TestLockCleanup(test.TestCase):
 
     def _get_sentinel_name(self, hostname, pid, thread='MainThread'):
         return os.path.join(FLAGS.lock_path,
-                            '%s.%s-%d' % (hostname, thread, pid))
+                            '%s-%s.%d' % (hostname, thread, pid))
 
     def _create_sentinel(self, hostname, pid, thread='MainThread'):
         name = self._get_sentinel_name(hostname, pid, thread)
diff --git a/nova/utils.py b/nova/utils.py
index de2da9f..01a52b5 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -986,7 +986,7 @@ def cleanup_file_locks():
         return
 
     hostname = socket.gethostname()
-    sentinel_re = hostname + r'\..*-(\d+$)'
+    sentinel_re = hostname + r'-.*\.(\d+$)'
     lockfile_re = r'nova-.*\.lock'
     files = os.listdir(FLAGS.lock_path)