]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Allow provisioning to reach max oversubscription
authorXing Yang <xing.yang@emc.com>
Wed, 3 Jun 2015 14:40:26 +0000 (10:40 -0400)
committerXing Yang <xing.yang@emc.com>
Wed, 3 Jun 2015 14:40:26 +0000 (10:40 -0400)
Currently if provisioned ratio is equal to max_over_subscription_ratio,
the capacity filter does not allow any more thin provisioning. This patch
makes a change so that thin provisioning is allowed if provisioned ratio
is equal to max_over_subscription_ratio; it will only stop provisioning
if provisioned ratio is greater than max_over_subscription_ratio.

Change-Id: Ibf13ef97472b80a1b59ffd4389a4ed2eacf67205
Partial-Bug: #1458976

cinder/scheduler/filters/capacity_filter.py
cinder/tests/unit/scheduler/test_host_filters.py

index be13e67f08b3a64707c891ba1d405c2ad5df2aca..f278e464d3e680c2a18a50878dba71bd504fa463 100644 (file)
@@ -89,7 +89,7 @@ class CapacityFilter(filters.BaseHostFilter):
                 host_state.max_over_subscription_ratio > 1):
             provisioned_ratio = ((host_state.provisioned_capacity_gb +
                                   volume_size) / total)
-            if provisioned_ratio >= host_state.max_over_subscription_ratio:
+            if provisioned_ratio > host_state.max_over_subscription_ratio:
                 LOG.warning(_LW(
                     "Insufficient free space for thin provisioning. "
                     "The ratio of provisioned capacity over total capacity "
index 70e82696d4a27fb8eac39a7e27210b86645b80ca..1271391bedee6459d0d8bf2cfdc1a449fe55688b 100644 (file)
@@ -138,6 +138,28 @@ class CapacityFilterTestCase(HostFiltersTestCase):
                                     'service': service})
         self.assertTrue(filt_cls.host_passes(host, filter_properties))
 
+    @mock.patch('cinder.utils.service_is_up')
+    def test_filter_thin_true_passes2(self, _mock_serv_is_up):
+        _mock_serv_is_up.return_value = True
+        filt_cls = self.class_map['CapacityFilter']()
+        filter_properties = {'size': 3000,
+                             'capabilities:thin_provisioning_support':
+                                 '<is> True',
+                             'capabilities:thick_provisioning_support':
+                                 '<is> False'}
+        service = {'disabled': False}
+        host = fakes.FakeHostState('host1',
+                                   {'total_capacity_gb': 500,
+                                    'free_capacity_gb': 200,
+                                    'provisioned_capacity_gb': 7000,
+                                    'max_over_subscription_ratio': 20,
+                                    'reserved_percentage': 5,
+                                    'thin_provisioning_support': True,
+                                    'thick_provisioning_support': False,
+                                    'updated_at': None,
+                                    'service': service})
+        self.assertTrue(filt_cls.host_passes(host, filter_properties))
+
     @mock.patch('cinder.utils.service_is_up')
     def test_filter_thin_false_passes(self, _mock_serv_is_up):
         _mock_serv_is_up.return_value = True