According to this documentation, https://docs.openstack.org/cinder/pike/admin/blockstorage-driver-filter-weighing.html, the GoodnessWeigher can be configured to operate independently of other Filters and Weights ( there is an example at the bottom of the page ). After configuring my scheduler to have:
scheduler_default_weighers = GoodnessWeigher
and my volume-types to be configured:
enabled_backends = volumes_one,volumes_two
[volumes_one]
goodness_function = "100"
[volumes_two]
goodness_function = "0"
If a volume is created without a volume-type, the scheduler fails with the following exception:
Traceback (most recent call last):
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/oslo_messaging/rpc/server.py", line 133, in _process_incoming
res = self.dispatcher.dispatch(message)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 150, in dispatch
return self._do_dispatch(endpoint, method, ctxt, args)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/oslo_messaging/rpc/dispatcher.py", line 121, in _do_dispatch
result = func(ctxt, **new_args)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/manager.py", line 400, in create_volume
filter_properties=filter_properties, volume=volume)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/manager.py", line 184, in create_volume
flow_engine.run()
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/taskflow/engines/action_engine/engine.py", line 247, in run
for _state in self.run_iter(timeout=timeout):
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/taskflow/engines/action_engine/engine.py", line 340, in run_iter
failure.Failure.reraise_if_any(er_failures)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/taskflow/types/failure.py", line 336, in reraise_if_any
failures[0].reraise()
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/taskflow/types/failure.py", line 343, in reraise
six.reraise(*self._exc_info)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/taskflow/engines/action_engine/executor.py", line 53, in _execute_task
result = task.execute(**arguments)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/flows/create_volume.py", line 144, in execute
common.error_out(volume, reason=e)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
self.force_reraise()
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
six.reraise(self.type_, self.value, self.tb)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/flows/create_volume.py", line 126, in execute
filter_properties)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/filter_scheduler.py", line 108, in schedule_create_volume
filter_properties)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/filter_scheduler.py", line 607, in _schedule
filter_properties)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/filter_scheduler.py", line 337, in _get_weighted_candidates
filter_properties)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/host_manager.py", line 432, in get_weighed_hosts
weight_properties)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/base_weight.py", line 134, in get_weighed_objects
weights = weigher.weigh_objects(weighed_objs, weighing_properties)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/base_weight.py", line 102, in weigh_objects
weight = self._weigh_object(obj.obj, weight_properties)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/weights/goodness.py", line 45, in _weigh_object
stats = self._generate_stats(host_state, weight_properties)
File "/openstack/venvs/cinder-14.2.14/lib/python2.7/site-packages/cinder/scheduler/weights/goodness.py", line 133, in _generate_stats
extra_specs = volume_type.get('extra_specs', {})
AttributeError: 'NoneType' object has no attribute 'get'
The offending lines are:
volume_type = weight_properties.get('volume_type', {})
extra_specs = volume_type.get('extra_specs', {})
where weight_properties["volume_type"] is a NoneType and this is being assigned to 'volume_type'. When the next line executes, the AttributeError is thrown.
I've patched the _generate_stats() function to:
volume_type = weight_properties.get('volume_type', {}) or {}
extra_specs = volume_type.get('extra_specs', {})
and I can now schedule non-typed volumes. I will have a patch for review shortly.
My deployment is OpenStack Newton, but the goodness module has not been updated up to current master ( 2018-04-15 ), which suggets that this problem exists in versions up to Rocky.
Fix proposed to branch: master /review. openstack. org/564339
Review: https:/