From: Xing Yang Date: Wed, 3 Jun 2015 14:40:26 +0000 (-0400) Subject: Allow provisioning to reach max oversubscription X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ab017d98b1bb39d218bd93970c0e561c685b7dbf;p=openstack-build%2Fcinder-build.git Allow provisioning to reach max oversubscription 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 --- diff --git a/cinder/scheduler/filters/capacity_filter.py b/cinder/scheduler/filters/capacity_filter.py index be13e67f0..f278e464d 100644 --- a/cinder/scheduler/filters/capacity_filter.py +++ b/cinder/scheduler/filters/capacity_filter.py @@ -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 " diff --git a/cinder/tests/unit/scheduler/test_host_filters.py b/cinder/tests/unit/scheduler/test_host_filters.py index 70e82696d..1271391be 100644 --- a/cinder/tests/unit/scheduler/test_host_filters.py +++ b/cinder/tests/unit/scheduler/test_host_filters.py @@ -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': + ' True', + 'capabilities:thick_provisioning_support': + ' 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