From fde90580590b30b474f77e269b0e767f3925ad0a Mon Sep 17 00:00:00 2001 From: Mandar Vaze Date: Thu, 5 Apr 2012 01:33:34 -0700 Subject: [PATCH] Introduced flag base_dir_name. Fixes bug 973194 rebased from master. If user faces locking related problem when two nova-compute hosts sharing same disk area via nfs, try to download same image into cache concurrently - Then base_dir_name can be set to "_base_$my_ip" in nova.conf Default value for base_dir_name is "_base" thus retaining existing behavior. Change-Id: Icff10ed75ba83f7256731614dc9e01e578b347a4 --- Authors | 1 + nova/tests/test_imagecache.py | 8 +++++--- nova/tests/test_libvirt.py | 7 ++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Authors b/Authors index e7b82281..7aa39267 100644 --- a/Authors +++ b/Authors @@ -124,6 +124,7 @@ Likitha Shetty Loganathan Parthipan Lorin Hochstein Lvov Maxim +Mandar Vaze Mandell Degerness Mandar Vaze Mark McClain diff --git a/nova/tests/test_imagecache.py b/nova/tests/test_imagecache.py index eaa05a4b..219d003b 100644 --- a/nova/tests/test_imagecache.py +++ b/nova/tests/test_imagecache.py @@ -36,6 +36,7 @@ from nova.virt.libvirt import utils as virtutils flags.DECLARE('instances_path', 'nova.compute.manager') +flags.DECLARE('base_dir_name', 'nova.compute.manager') FLAGS = flags.FLAGS LOG = log.getLogger(__name__) @@ -155,7 +156,7 @@ class ImageCacheManagerTestCase(test.TestCase): self.stubs.Set(virtutils, 'get_disk_backing_file', lambda x: 'e97222e91fc4241f49a7f520d1dcf446751129b3_sm') - found = os.path.join(FLAGS.instances_path, '_base', + found = os.path.join(FLAGS.instances_path, FLAGS.base_dir_name, 'e97222e91fc4241f49a7f520d1dcf446751129b3_sm') image_cache_manager = imagecache.ImageCacheManager() @@ -177,7 +178,7 @@ class ImageCacheManagerTestCase(test.TestCase): lambda x: ('e97222e91fc4241f49a7f520d1dcf446751129b3_' '10737418240')) - found = os.path.join(FLAGS.instances_path, '_base', + found = os.path.join(FLAGS.instances_path, FLAGS.base_dir_name, 'e97222e91fc4241f49a7f520d1dcf446751129b3_' '10737418240') @@ -198,7 +199,7 @@ class ImageCacheManagerTestCase(test.TestCase): self.stubs.Set(virtutils, 'get_disk_backing_file', lambda x: 'e97222e91fc4241f49a7f520d1dcf446751129b3_sm') - found = os.path.join(FLAGS.instances_path, '_base', + found = os.path.join(FLAGS.instances_path, FLAGS.base_dir_name, 'e97222e91fc4241f49a7f520d1dcf446751129b3_sm') image_cache_manager = imagecache.ImageCacheManager() @@ -521,6 +522,7 @@ class ImageCacheManagerTestCase(test.TestCase): hashed_42 = '92cfceb39d57d914ed8b14d0e37643de0797ae56' self.flags(instances_path='/instance_path') + self.flags(base_dir_name='_base') self.flags(remove_unused_base_images=True) base_file_list = ['00000001', diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 47201361..5a7ac8b8 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -325,7 +325,7 @@ class CacheConcurrencyTestCase(test.TestCase): self.flags(instances_path='nova.compute.manager') def fake_exists(fname): - basedir = os.path.join(FLAGS.instances_path, '_base') + basedir = os.path.join(FLAGS.instances_path, FLAGS.base_dir_name) if fname == basedir: return True return False @@ -1393,9 +1393,10 @@ class LibvirtConnTestCase(test.TestCase): if os.path.isdir(path): shutil.rmtree(path) - path = os.path.join(FLAGS.instances_path, '_base') + path = os.path.join(FLAGS.instances_path, FLAGS.base_dir_name) if os.path.isdir(path): - shutil.rmtree(os.path.join(FLAGS.instances_path, '_base')) + shutil.rmtree(os.path.join(FLAGS.instances_path, + FLAGS.base_dir_name)) def test_get_host_ip_addr(self): conn = connection.LibvirtConnection(False)