]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Downgrade 'infinite' and 'unknown' capacity in weigher
authorZhiteng Huang <zhithuang@ebaysf.com>
Thu, 18 Sep 2014 22:02:55 +0000 (15:02 -0700)
committerZhiteng Huang <zhithuang@ebaysf.com>
Tue, 23 Sep 2014 04:49:58 +0000 (12:49 +0800)
When FilterScheduler was first introduced into Cinder, drivers were
required for the first time to report capacity. Some drivers preferred
to report 'infinite' or 'unknown' capacity because they were doing
thin-provisioning or the total capacity kept increasing. Now that we
have better support for thin-provisioning and we do find unrealistic
capacity couldn't do us any good in making optimal scheduling decision,
because 'infinite' and 'unknown' would always have the highest weight
when the weight multiplier is positive, which in most cases it is.

Drivers are expected to avoid sending 'infinite' 'unknown' capacity
anymore, instead, should report an actual real number for total/free
capacity.

This fix doesn't fix the driver, instead a small tweak is added to
CapacityWeigher in order to downgrade those drivers who report
'infinite' or 'unknown' as free capacity.  In particular, those who
report 'infinite'/'unknown' free capacity will be adjusted to be the
one has lowest weight, no matter in 'spreading' (weight multiplier>0)
or 'stacking' (weight multiplier<0) mode.

DocImpact

Change-Id: Ied087386a1a2f43e6a77499a817d5c637ef448f6
Partial-bug: #1350638

cinder/scheduler/weights/capacity.py
cinder/tests/scheduler/fakes.py
cinder/tests/scheduler/test_capacity_weigher.py

index 099c58d2119401408e8079f115318a4c4829cab9..7ad78db8359efa7ff515ac461a9a63f02b5e3a70 100644 (file)
@@ -67,7 +67,11 @@ class CapacityWeigher(weights.BaseHostWeigher):
         if free_space == 'infinite' or free_space == 'unknown':
             #(zhiteng) 'infinite' and 'unknown' are treated the same
             # here, for sorting purpose.
-            free = float('inf')
+
+            # As a partial fix for bug #1350638, 'infinite' and 'unknown' are
+            # given the lowest weight to discourage driver from report such
+            # capacity anymore.
+            free = -1 if CONF.capacity_weight_multiplier > 0 else float('inf')
         else:
             free = math.floor(host_state.free_capacity_gb * (1 - reserved))
         return free
index 48c9cfc3a3683f42538f8df517bf47d114ea0f87..1ce71c34a4cbf651d15487dbd4a852554d0f3c73 100644 (file)
@@ -57,8 +57,8 @@ class FakeHostManager(host_manager.HostManager):
                       'volume_backend_name': 'lvm4',
                       'timestamp': None,
                       'consistencygroup_support': True},
-            'host5': {'total_capacity_gb': 2048,
-                      'free_capacity_gb': 500,
+            'host5': {'total_capacity_gb': 'infinite',
+                      'free_capacity_gb': 'unknown',
                       'allocated_capacity_gb': 1548,
                       'reserved_percentage': 5,
                       'timestamp': None},
index cc1df28e71ba00948009b949cb02b43d82ee6a67..c28f384ae7a778a27b1c6d532d244dba2900ccb1 100644 (file)
@@ -59,6 +59,7 @@ class CapacityWeigherTestCase(test.TestCase):
         # host2: free_capacity_gb=300, free=300*(1-0.1)
         # host3: free_capacity_gb=512, free=256
         # host4: free_capacity_gb=200, free=200*(1-0.05)
+        # host5: free_capacity_gb=unknown free=-1
 
         # so, host1 should win:
         weighed_host = self._get_weighed_host(hostinfo_list)
@@ -74,6 +75,7 @@ class CapacityWeigherTestCase(test.TestCase):
         # host2: free_capacity_gb=300, free=-300*(1-0.1)
         # host3: free_capacity_gb=512, free=-256
         # host4: free_capacity_gb=200, free=-200*(1-0.05)
+        # host5: free_capacity_gb=unknown free=-float('inf')
 
         # so, host4 should win:
         weighed_host = self._get_weighed_host(hostinfo_list)
@@ -89,6 +91,7 @@ class CapacityWeigherTestCase(test.TestCase):
         # host2: free_capacity_gb=300, free=300*(1-0.1)*2
         # host3: free_capacity_gb=512, free=256*2
         # host4: free_capacity_gb=200, free=200*(1-0.05)*2
+        # host5: free_capacity_gb=unknown free=-2
 
         # so, host1 should win:
         weighed_host = self._get_weighed_host(hostinfo_list)