]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Scheduler should not select down volume managers
authorOllie Leahy <oliver.leahy@hp.com>
Thu, 4 Jul 2013 13:58:08 +0000 (13:58 +0000)
committerOllie Leahy <oliver.leahy@hp.com>
Thu, 4 Jul 2013 16:50:59 +0000 (16:50 +0000)
Currently volume managers that are not disabled, but are not running
may be selected by the scheduler for volume creation operations.

Change-Id: Ia06a3da8b31eef918d55aaaf71f863683c721026
Fixes: bug #1197741
cinder/scheduler/host_manager.py
cinder/tests/scheduler/test_host_manager.py

index f1f51487baca4a5b09e317306f1d08795c23aae2..2683f87157af346a976d02f02998e0e8ff8aaacb 100644 (file)
@@ -263,6 +263,7 @@ class HostManager(object):
         # Get resource usage across the available volume nodes:
         topic = CONF.volume_topic
         volume_services = db.service_get_all_by_topic(context, topic)
+        self.host_state_map.clear()
         for service in volume_services:
             host = service['host']
             if not utils.service_is_up(service) or service['disabled']:
index 960d59bd61fee6330f6604eb7a2a015e3b771f5c..c6588785f355c839b954679502c67263bc2e056c 100644 (file)
@@ -141,9 +141,28 @@ class HostManagerTestCase(test.TestCase):
 
         self.mox.StubOutWithMock(db, 'service_get_all_by_topic')
         self.mox.StubOutWithMock(host_manager.LOG, 'warn')
+        self.mox.StubOutWithMock(host_manager.utils, 'service_is_up')
 
         ret_services = fakes.VOLUME_SERVICES
         db.service_get_all_by_topic(context, topic).AndReturn(ret_services)
+        host_manager.utils.service_is_up(ret_services[0]).AndReturn(True)
+        host_manager.utils.service_is_up(ret_services[1]).AndReturn(True)
+        host_manager.utils.service_is_up(ret_services[2]).AndReturn(True)
+        host_manager.utils.service_is_up(ret_services[3]).AndReturn(True)
+        host_manager.utils.service_is_up(ret_services[4]).AndReturn(True)
+        # Disabled service
+        host_manager.LOG.warn("volume service is down or disabled. "
+                              "(host: host5)")
+
+        db.service_get_all_by_topic(context, topic).AndReturn(ret_services)
+        host_manager.utils.service_is_up(ret_services[0]).AndReturn(True)
+        host_manager.utils.service_is_up(ret_services[1]).AndReturn(True)
+        host_manager.utils.service_is_up(ret_services[2]).AndReturn(True)
+        host_manager.utils.service_is_up(ret_services[3]).AndReturn(False)
+        # Stopped service
+        host_manager.LOG.warn("volume service is down or disabled. "
+                              "(host: host4)")
+        host_manager.utils.service_is_up(ret_services[4]).AndReturn(True)
         # Disabled service
         host_manager.LOG.warn("volume service is down or disabled. "
                               "(host: host5)")
@@ -160,6 +179,16 @@ class HostManagerTestCase(test.TestCase):
             self.assertEqual(host_state_map[host].service,
                              volume_node)
 
+        self.host_manager.get_all_host_states(context)
+        host_state_map = self.host_manager.host_state_map
+
+        self.assertEqual(len(host_state_map), 3)
+        for i in xrange(3):
+            volume_node = fakes.VOLUME_SERVICES[i]
+            host = volume_node['host']
+            self.assertEqual(host_state_map[host].service,
+                             volume_node)
+
 
 class HostStateTestCase(test.TestCase):
     """Test case for HostState class"""