GoodnessWeigher schedules non-type volumes
If the GoodnessWeigher is configured to be the only active weigher within the scheduler, it cannot schedule a non-typed volumed for creation. This patch adds a safety assignement to the weigher stats generation to allow for scheduling untyped volumes. This patch safely assigns a dictionary data-type to "volume_type" in the event that: weight_properties = { "volume_type": None, etc.. } Volumes created with a volume-type will not cause an exception and will be scheduled with the volume-type and back-end as configured. Closes-Bug: 1766966 Change-Id: I7bc77ab02154aee80282e54b19a242bdea0a78ec Signed-off-by: Eric M Gonzalez <eric@awnix.com>
This commit is contained in:
parent
e02e4f8fb3
commit
34d75ca1a6
|
@ -126,12 +126,12 @@ class GoodnessWeigher(weights.BaseHostWeigher):
|
|||
host_caps['goodness_function'] is not None):
|
||||
goodness_function = six.text_type(host_caps['goodness_function'])
|
||||
|
||||
qos_specs = weight_properties.get('qos_specs', {})
|
||||
qos_specs = weight_properties.get('qos_specs', {}) or {}
|
||||
|
||||
volume_type = weight_properties.get('volume_type', {})
|
||||
volume_type = weight_properties.get('volume_type', {}) or {}
|
||||
extra_specs = volume_type.get('extra_specs', {})
|
||||
|
||||
request_spec = weight_properties.get('request_spec', {})
|
||||
request_spec = weight_properties.get('request_spec', {}) or {}
|
||||
volume_stats = request_spec.get('volume_properties', {})
|
||||
|
||||
stats = {
|
||||
|
|
|
@ -193,3 +193,18 @@ class GoodnessWeigherTestCase(test.TestCase):
|
|||
weight_properties = {}
|
||||
weight = weigher._weigh_object(host_state, weight_properties)
|
||||
self.assertEqual(0, weight)
|
||||
|
||||
def test_goodness_weigher_untyped_volume(self):
|
||||
weigher = goodness.GoodnessWeigher()
|
||||
host_state = fakes.FakeBackendState('host1', {
|
||||
'host': 'host.example.com',
|
||||
'capabilities': {
|
||||
'goodness_function': '67'
|
||||
}
|
||||
})
|
||||
|
||||
weight_properties = {
|
||||
'volume_type': None,
|
||||
}
|
||||
weight = weigher._weigh_object(host_state, weight_properties)
|
||||
self.assertEqual(67, weight)
|
||||
|
|
Loading…
Reference in New Issue