Fix volume creation with no volume type
Allow creation of volumes with no volume type. This
has always been supported but was accidentally broken
with recent changes.
If a type is not specified, the capabilities filter can
skip processing type-related checks.
This reverts most of 8a594c8
"Fix NoneType Attribute Error"
Closes-Bug: #1610073
Co-Author: Tom Barron <tbarron@redhat.com>
Change-Id: I7cb8435af379099c60f0f84d7bad4a6660d2d636
This commit is contained in:
parent
bc9abc1c51
commit
9abeca399e
@ -270,10 +270,6 @@ class FilterScheduler(driver.Scheduler):
|
||||
self._populate_retry(filter_properties,
|
||||
request_spec['volume_properties'])
|
||||
|
||||
if resource_type is None:
|
||||
msg = _("volume_type cannot be None")
|
||||
raise exception.InvalidVolumeType(reason=msg)
|
||||
|
||||
request_spec_dict = jsonutils.to_primitive(request_spec)
|
||||
|
||||
filter_properties.update({'context': context,
|
||||
@ -427,7 +423,7 @@ class FilterScheduler(driver.Scheduler):
|
||||
if not weighed_hosts:
|
||||
LOG.warning(_LW('No weighed hosts found for volume '
|
||||
'with properties: %s'),
|
||||
filter_properties['request_spec']['volume_type'])
|
||||
filter_properties['request_spec'].get('volume_type'))
|
||||
return None
|
||||
return self._choose_top_host(weighed_hosts, request_spec)
|
||||
|
||||
|
@ -30,6 +30,10 @@ class CapabilitiesFilter(filters.BaseHostFilter):
|
||||
Check that the capabilities provided by the services satisfy
|
||||
the extra specs associated with the resource type.
|
||||
"""
|
||||
|
||||
if not resource_type:
|
||||
return True
|
||||
|
||||
extra_specs = resource_type.get('extra_specs', [])
|
||||
if not extra_specs:
|
||||
return True
|
||||
|
@ -147,7 +147,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
||||
'size': 1},
|
||||
'volume_id': fake.VOLUME_ID}
|
||||
request_spec = objects.RequestSpec.from_primitives(request_spec)
|
||||
self.assertRaises(exception.InvalidVolumeType,
|
||||
self.assertRaises(exception.NoValidHost,
|
||||
sched.schedule_create_volume,
|
||||
fake_context,
|
||||
request_spec,
|
||||
|
Loading…
Reference in New Issue
Block a user