summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-10-16 01:21:40 +0000
committerGerrit Code Review <review@openstack.org>2016-10-16 01:21:40 +0000
commit787dda278d3b8f965dbaed7b52d19b62163cc12e (patch)
tree4bae7e377b6f8cdabe173e0fb6784eedf3b92f9b
parentfad76268ac84eb736acc5fd7f5afc20d5f94d208 (diff)
parenteeb23c78914891a5a6943c09c87aceb720d45f58 (diff)
downloadnova-787dda278d3b8f965dbaed7b52d19b62163cc12e.tar.gz
Merge "refresh instances_path when shared storage used" into stable/mitaka
-rw-r--r--nova/tests/unit/virt/libvirt/test_driver.py20
-rw-r--r--nova/virt/libvirt/driver.py8
2 files changed, 28 insertions, 0 deletions
diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py
index 059999748f..6276f11ca0 100644
--- a/nova/tests/unit/virt/libvirt/test_driver.py
+++ b/nova/tests/unit/virt/libvirt/test_driver.py
@@ -6428,6 +6428,26 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr.check_can_live_migrate_destination_cleanup(self.context,
dest_check_data)
+ @mock.patch('os.path.exists', return_value=True)
+ @mock.patch('os.utime')
+ def test_check_shared_storage_test_file_exists(self, mock_utime,
+ mock_path_exists):
+ tmpfile_path = os.path.join(CONF.instances_path, 'tmp123')
+ drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
+ self.assertTrue(drvr._check_shared_storage_test_file('tmp123'))
+ mock_utime.assert_called_once_with(CONF.instances_path, None)
+ mock_path_exists.assert_called_once_with(tmpfile_path)
+
+ @mock.patch('os.path.exists', return_value=False)
+ @mock.patch('os.utime')
+ def test_check_shared_storage_test_file_does_not_exist(self, mock_utime,
+ mock_path_exists):
+ tmpfile_path = os.path.join(CONF.instances_path, 'tmp123')
+ drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
+ self.assertFalse(drvr._check_shared_storage_test_file('tmp123'))
+ mock_utime.assert_called_once_with(CONF.instances_path, None)
+ mock_path_exists.assert_called_once_with(tmpfile_path)
+
def _mock_can_live_migrate_source(self, block_migration=False,
is_shared_block_storage=False,
is_shared_instance_path=False,
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 8c1e27a8c7..78f9c7ca01 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -5749,6 +5749,14 @@ class LibvirtDriver(driver.ComputeDriver):
Cannot confirm tmpfile return False.
"""
+ # NOTE(tpatzig): if instances_path is a shared volume that is
+ # under heavy IO (many instances on many compute nodes),
+ # then checking the existence of the testfile fails,
+ # just because it takes longer until the client refreshes and new
+ # content gets visible.
+ # os.utime (like touch) on the directory forces the client to refresh.
+ os.utime(CONF.instances_path, None)
+
tmp_file = os.path.join(CONF.instances_path, filename)
if not os.path.exists(tmp_file):
return False