Fix AttributeError without share type provided
A share_type is set to None, when creating a new share without specifying a share type and a default_share_type option is set to None. Make scheduler check presense of a share type and raise error if it is absent. The raised error is logged finally. Closes-Bug: #1477789 Change-Id: I6cdf3ce3940af4095b8e6afca4861ad1c2fc4795
This commit is contained in:
parent
658ba0d631
commit
f89f0f2b69
|
@ -120,6 +120,12 @@ class FilterScheduler(driver.Scheduler):
|
|||
# 'volume_XX' to 'resource_XX' will make both filters happy.
|
||||
resource_properties = share_properties.copy()
|
||||
share_type = request_spec.get("share_type", {})
|
||||
if not share_type:
|
||||
msg = _("You must create a share type in advance,"
|
||||
" and specify in request body or"
|
||||
" set default_share_type in manila.conf.")
|
||||
LOG.error(msg)
|
||||
raise exception.InvalidParameterValue(err=msg)
|
||||
|
||||
extra_specs = share_type.get('extra_specs', {})
|
||||
|
||||
|
|
|
@ -84,6 +84,16 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
|||
self.assertIsNotNone(weighed_host.obj)
|
||||
self.assertTrue(_mock_service_get_all_by_topic.called)
|
||||
|
||||
def test_schedule_share_type_is_none(self):
|
||||
sched = fakes.FakeFilterScheduler()
|
||||
request_spec = {
|
||||
'share_type': None,
|
||||
'share_properties': {'project_id': 1, 'size': 1},
|
||||
}
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
sched._schedule_share,
|
||||
self.context, request_spec)
|
||||
|
||||
def test_max_attempts(self):
|
||||
self.flags(scheduler_max_attempts=4)
|
||||
sched = fakes.FakeFilterScheduler()
|
||||
|
|
Loading…
Reference in New Issue