From 0c2ce65014be15430b37df83e12d970052a028b4 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Thu, 28 Feb 2013 18:34:07 +0000 Subject: [PATCH] Add some useful log to filter scheduler. When the filter scheduler is unable to find a suitable host to deploy a volume on it simply logged a warning "not hosts found". This isn't very helpful, so this patch adds some logging info as far as why no valid host was available. This just focuses on the capacity filtering as that's where I've commonly seen this issue particularly in tempest runs. Also noticed that the get status was checking for "if Not capacity", but this is wrong because free capacity==0 would be interpretted as failing to get capacity. Change this to "if is None". Fixes bug: 1136147 Change-Id: Ia1ce508826ee69ae68a250ea68616909c59974e5 --- cinder/scheduler/filters/capacity_filter.py | 12 +++++++++--- cinder/scheduler/host_manager.py | 2 +- cinder/scheduler/manager.py | 2 +- cinder/tests/scheduler/test_host_manager.py | 6 +++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cinder/scheduler/filters/capacity_filter.py b/cinder/scheduler/filters/capacity_filter.py index fe35033df..1f5ec624e 100644 --- a/cinder/scheduler/filters/capacity_filter.py +++ b/cinder/scheduler/filters/capacity_filter.py @@ -32,10 +32,10 @@ class CapacityFilter(filters.BaseHostFilter): """Return True if host has sufficient capacity.""" volume_size = filter_properties.get('size') - if not host_state.free_capacity_gb: + if host_state.free_capacity_gb is None: # Fail Safe - LOG.warning(_("Free capacity not set;" - "volume node info collection broken.")) + LOG.error(_("Free capacity not set: " + "volume node info collection broken.")) return False free_space = host_state.free_capacity_gb @@ -47,5 +47,11 @@ class CapacityFilter(filters.BaseHostFilter): return True reserved = float(host_state.reserved_percentage) / 100 free = math.floor(free_space * (1 - reserved)) + if free < volume_size: + LOG.warning(_("Insufficient free space for volume creation " + "(requested / avail): " + "%(requested)s/%(available)s") + % {'requested': volume_size, + 'available': free}) return free >= volume_size diff --git a/cinder/scheduler/host_manager.py b/cinder/scheduler/host_manager.py index 2029487a7..9dd2182f0 100644 --- a/cinder/scheduler/host_manager.py +++ b/cinder/scheduler/host_manager.py @@ -99,7 +99,7 @@ class HostState(object): # Mutable available resources. # These will change as resources are virtually "consumed". self.total_capacity_gb = 0 - self.free_capacity_gb = 0 + self.free_capacity_gb = None self.reserved_percentage = 0 self.updated = None diff --git a/cinder/scheduler/manager.py b/cinder/scheduler/manager.py index 6966e2d84..fa0852d70 100644 --- a/cinder/scheduler/manager.py +++ b/cinder/scheduler/manager.py @@ -116,7 +116,7 @@ class SchedulerManager(manager.Manager): def _set_volume_state_and_notify(self, method, updates, context, ex, request_spec): - LOG.warning(_("Failed to schedule_%(method)s: %(ex)s") % locals()) + LOG.error(_("Failed to schedule_%(method)s: %(ex)s") % locals()) volume_state = updates['volume_state'] properties = request_spec.get('volume_properties', {}) diff --git a/cinder/tests/scheduler/test_host_manager.py b/cinder/tests/scheduler/test_host_manager.py index f820b1141..6196444dc 100644 --- a/cinder/tests/scheduler/test_host_manager.py +++ b/cinder/tests/scheduler/test_host_manager.py @@ -165,7 +165,7 @@ class HostStateTestCase(test.TestCase): def test_update_from_volume_capability(self): fake_host = host_manager.HostState('host1') - self.assertEqual(fake_host.free_capacity_gb, 0) + self.assertEqual(fake_host.free_capacity_gb, None) volume_capability = {'total_capacity_gb': 1024, 'free_capacity_gb': 512, @@ -177,7 +177,7 @@ class HostStateTestCase(test.TestCase): def test_update_from_volume_infinite_capability(self): fake_host = host_manager.HostState('host1') - self.assertEqual(fake_host.free_capacity_gb, 0) + self.assertEqual(fake_host.free_capacity_gb, None) volume_capability = {'total_capacity_gb': 'infinite', 'free_capacity_gb': 'infinite', @@ -190,7 +190,7 @@ class HostStateTestCase(test.TestCase): def test_update_from_volume_unknown_capability(self): fake_host = host_manager.HostState('host1') - self.assertEqual(fake_host.free_capacity_gb, 0) + self.assertEqual(fake_host.free_capacity_gb, None) volume_capability = {'total_capacity_gb': 'infinite', 'free_capacity_gb': 'unknown', -- 2.45.2