summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-07-13 02:20:26 +0000
committerGerrit Code Review <review@openstack.org>2018-07-13 02:20:26 +0000
commitaa50408cbc357c0ed3bda0bbb64ba675db5e42ef (patch)
treedc009cbef6d85988e84fe5cea0574a3040a6d358
parenteceaade9f12dbcca320a8b64ad28e1dc6bfc7e4c (diff)
parentf33b234aa02a2f682455cbc01758a7330d64e6ae (diff)
Merge "Make scheduler check online_extend_support capability"
-rw-r--r--cinder/interface/volume_driver.py6
-rw-r--r--cinder/scheduler/filters/capabilities_filter.py20
-rw-r--r--cinder/tests/unit/scheduler/fakes.py2
-rw-r--r--cinder/tests/unit/scheduler/test_filter_scheduler.py36
-rw-r--r--doc/source/contributor/drivers.rst5
-rw-r--r--releasenotes/notes/bug-1765182-bcafd577f4b81eb6.yaml5
6 files changed, 71 insertions, 3 deletions
diff --git a/cinder/interface/volume_driver.py b/cinder/interface/volume_driver.py
index d8603db..2d31676 100644
--- a/cinder/interface/volume_driver.py
+++ b/cinder/interface/volume_driver.py
@@ -132,6 +132,9 @@ class VolumeDriverCore(base.CinderInterface):
132 * sparse_copy_volume (Boolean) 132 * sparse_copy_volume (Boolean)
133 Whether copies performed by the volume manager for operations such 133 Whether copies performed by the volume manager for operations such
134 as migration should attempt to preserve sparseness. 134 as migration should attempt to preserve sparseness.
135 * online_extend_support (Boolean)
136 Whether the backend supports in-use volume extend or not. Defaults
137 to True.
135 138
136 The returned dict may also contain a list, "pools", which has a similar 139 The returned dict may also contain a list, "pools", which has a similar
137 dict for each pool being used with the backend. 140 dict for each pool being used with the backend.
@@ -255,6 +258,9 @@ class VolumeDriverCore(base.CinderInterface):
255 258
256 :param volume: The volume to extend. 259 :param volume: The volume to extend.
257 :param new_size: The new desired size of the volume. 260 :param new_size: The new desired size of the volume.
261
262 Note that if the volume backend doesn't support extending an in-use
263 volume, the driver should report online_extend_support=False.
258 """ 264 """
259 265
260 def create_snapshot(self, snapshot): 266 def create_snapshot(self, snapshot):
diff --git a/cinder/scheduler/filters/capabilities_filter.py b/cinder/scheduler/filters/capabilities_filter.py
index d98caa4..fb2fd90 100644
--- a/cinder/scheduler/filters/capabilities_filter.py
+++ b/cinder/scheduler/filters/capabilities_filter.py
@@ -15,6 +15,7 @@
15 15
16from oslo_log import log as logging 16from oslo_log import log as logging
17 17
18from cinder.objects.fields import VolumeAttachStatus
18from cinder.scheduler import filters 19from cinder.scheduler import filters
19from cinder.scheduler.filters import extra_specs_ops 20from cinder.scheduler.filters import extra_specs_ops
20 21
@@ -24,13 +25,27 @@ LOG = logging.getLogger(__name__)
24class CapabilitiesFilter(filters.BaseBackendFilter): 25class CapabilitiesFilter(filters.BaseBackendFilter):
25 """BackendFilter to work with resource (instance & volume) type records.""" 26 """BackendFilter to work with resource (instance & volume) type records."""
26 27
27 def _satisfies_extra_specs(self, capabilities, resource_type): 28 def _satisfies_extra_specs(self, capabilities, filter_properties):
28 """Check if capabilities satisfy resource type requirements. 29 """Check if capabilities satisfy resource type requirements.
29 30
30 Check that the capabilities provided by the services satisfy 31 Check that the capabilities provided by the services satisfy
31 the extra specs associated with the resource type. 32 the extra specs associated with the resource type.
32 """ 33 """
33 34
35 req_spec = filter_properties.get('request_spec')
36 if req_spec and req_spec.get('operation') == 'extend_volume':
37 # NOTE(erlon): By default, cinder considers that every backend
38 # supports volume online extending. Those backends that don't
39 # support it should report online_extend_support=False.
40 online_extends = capabilities.get('online_extend_support', True)
41 if online_extends is False:
42 vol_prop = req_spec.get('volume_properties')
43 attach_status = vol_prop.get('attach_status')
44 if attach_status != VolumeAttachStatus.DETACHED:
45 LOG.debug("Backend doesn't support attached volume extend")
46 return False
47
48 resource_type = filter_properties.get('resource_type')
34 if not resource_type: 49 if not resource_type:
35 return True 50 return True
36 51
@@ -80,9 +95,8 @@ class CapabilitiesFilter(filters.BaseBackendFilter):
80 # Note(zhiteng) Currently only Cinder and Nova are using 95 # Note(zhiteng) Currently only Cinder and Nova are using
81 # this filter, so the resource type is either instance or 96 # this filter, so the resource type is either instance or
82 # volume. 97 # volume.
83 resource_type = filter_properties.get('resource_type')
84 if not self._satisfies_extra_specs(backend_state.capabilities, 98 if not self._satisfies_extra_specs(backend_state.capabilities,
85 resource_type): 99 filter_properties):
86 LOG.debug("%(backend_state)s fails resource_type extra_specs " 100 LOG.debug("%(backend_state)s fails resource_type extra_specs "
87 "requirements", {'backend_state': backend_state}) 101 "requirements", {'backend_state': backend_state})
88 return False 102 return False
diff --git a/cinder/tests/unit/scheduler/fakes.py b/cinder/tests/unit/scheduler/fakes.py
index a90dd19..200761d 100644
--- a/cinder/tests/unit/scheduler/fakes.py
+++ b/cinder/tests/unit/scheduler/fakes.py
@@ -39,6 +39,7 @@ SERVICE_STATES = {
39 'volume_backend_name': 'lvm1', 39 'volume_backend_name': 'lvm1',
40 'timestamp': UTC_NOW, 40 'timestamp': UTC_NOW,
41 'multiattach': True, 41 'multiattach': True,
42 'online_extend_support': True,
42 'uuid': 'a3a593da-7f8d-4bb7-8b4c-f2bc1e0b4824'}, 43 'uuid': 'a3a593da-7f8d-4bb7-8b4c-f2bc1e0b4824'},
43 'host2': {'total_capacity_gb': 2048, 44 'host2': {'total_capacity_gb': 2048,
44 'free_capacity_gb': 300, 45 'free_capacity_gb': 300,
@@ -50,6 +51,7 @@ SERVICE_STATES = {
50 'reserved_percentage': 10, 51 'reserved_percentage': 10,
51 'volume_backend_name': 'lvm2', 52 'volume_backend_name': 'lvm2',
52 'timestamp': UTC_NOW, 53 'timestamp': UTC_NOW,
54 'online_extend_support': False,
53 'uuid': '4200b32b-0bf9-436c-86b2-0675f6ac218e'}, 55 'uuid': '4200b32b-0bf9-436c-86b2-0675f6ac218e'},
54 'host3': {'total_capacity_gb': 512, 56 'host3': {'total_capacity_gb': 512,
55 'free_capacity_gb': 256, 57 'free_capacity_gb': 256,
diff --git a/cinder/tests/unit/scheduler/test_filter_scheduler.py b/cinder/tests/unit/scheduler/test_filter_scheduler.py
index fad545a..1fbf136 100644
--- a/cinder/tests/unit/scheduler/test_filter_scheduler.py
+++ b/cinder/tests/unit/scheduler/test_filter_scheduler.py
@@ -427,6 +427,42 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
427 self.assertTrue(_mock_service_get_topic.called) 427 self.assertTrue(_mock_service_get_topic.called)
428 428
429 @mock.patch('cinder.db.service_get_all') 429 @mock.patch('cinder.db.service_get_all')
430 def test_backend_passes_filters_online_extend_support_happy_day(
431 self, _mock_service_get_topic):
432 """Do a successful online extend with backend_passes_filters()."""
433 sched, ctx = self._backend_passes_filters_setup(
434 _mock_service_get_topic)
435 request_spec = {'volume_id': fake.VOLUME_ID,
436 'volume_type': {'name': 'LVM_iSCSI'},
437 'volume_properties': {'project_id': 1,
438 'size': 1,
439 'attach_status': 'attached'},
440 'operation': 'extend_volume'}
441 request_spec = objects.RequestSpec.from_primitives(request_spec)
442 # host1#lvm1 has online_extend_support = True
443 sched.backend_passes_filters(ctx, 'host1#lvm1', request_spec, {})
444 self.assertTrue(_mock_service_get_topic.called)
445
446 @mock.patch('cinder.db.service_get_all')
447 def test_backend_passes_filters_no_online_extend_support(
448 self, _mock_service_get_topic):
449 """Fail the host due to lack of online extend support."""
450 sched, ctx = self._backend_passes_filters_setup(
451 _mock_service_get_topic)
452 request_spec = {'volume_id': fake.VOLUME_ID,
453 'volume_type': {'name': 'LVM_iSCSI'},
454 'volume_properties': {'project_id': 1,
455 'size': 1,
456 'attach_status': 'attached'},
457 'operation': 'extend_volume'}
458 request_spec = objects.RequestSpec.from_primitives(request_spec)
459 # host2#lvm2 has online_extend_support = False
460 self.assertRaises(exception.NoValidBackend,
461 sched.backend_passes_filters,
462 ctx, 'host2#lvm2', request_spec, {})
463 self.assertTrue(_mock_service_get_topic.called)
464
465 @mock.patch('cinder.db.service_get_all')
430 def test_retype_policy_never_migrate_pass(self, _mock_service_get_topic): 466 def test_retype_policy_never_migrate_pass(self, _mock_service_get_topic):
431 # Retype should pass if current host passes filters and 467 # Retype should pass if current host passes filters and
432 # policy=never. host4 doesn't have enough space to hold an additional 468 # policy=never. host4 doesn't have enough space to hold an additional
diff --git a/doc/source/contributor/drivers.rst b/doc/source/contributor/drivers.rst
index dbb1ec1..ddc4af9 100644
--- a/doc/source/contributor/drivers.rst
+++ b/doc/source/contributor/drivers.rst
@@ -87,6 +87,11 @@ the backend cannot report the value or 'infinite' if the backend has no upper
87limit. But, it is recommended to report real values as the Cinder scheduler 87limit. But, it is recommended to report real values as the Cinder scheduler
88assigns lowest weight to any storage backend reporting 'unknown' or 'infinite'. 88assigns lowest weight to any storage backend reporting 'unknown' or 'infinite'.
89 89
90**NOTE:** By default, Cinder assumes that the driver supports attached volume
91extending. If it doesn't, it should report 'online_extend_support=False'.
92Otherwise the scheduler will attempt to perform the operation, and may leave
93the volume in 'error_extending' state.
94
90Feature Enforcement 95Feature Enforcement
91------------------- 96-------------------
92 97
diff --git a/releasenotes/notes/bug-1765182-bcafd577f4b81eb6.yaml b/releasenotes/notes/bug-1765182-bcafd577f4b81eb6.yaml
new file mode 100644
index 0000000..948c58c
--- /dev/null
+++ b/releasenotes/notes/bug-1765182-bcafd577f4b81eb6.yaml
@@ -0,0 +1,5 @@
1---
2fixes:
3 - |
4 Make Cinder scheduler check if backend reports `online_extend_support`
5 before performing an online extend operation.