Cleanup soft (anti)affinity weight multiplier options
This resolves the TODO from Ocata change: I8871b628f0ab892830ceeede68db16948cb293c8 By adding a min=0.0 value to the soft affinity weight multiplier configuration options. It also removes the deprecated [DEFAULT] group alias from Ocata change: I3f48e52815e80c99612bcd10cb53331a8c995fc3 Change-Id: I79e191010adbc0ec0ed02c9d589106debbf90ea8
This commit is contained in:
parent
8ef3d253a0
commit
313becd5ff
@ -871,16 +871,14 @@ Hosts and cells are weighted based on the following options in the
|
||||
- ``io_ops_weight_multiplier``
|
||||
- Multiplier used for weighing host I/O operations. A negative value means
|
||||
a preference to choose light workload compute hosts.
|
||||
* - [DEFAULT]
|
||||
* - [filter_scheduler]
|
||||
- ``soft_affinity_weight_multiplier``
|
||||
- Multiplier used for weighing hosts for group soft-affinity. Only a
|
||||
positive value is meaningful. Negative means that the behavior will
|
||||
change to the opposite, which is soft-anti-affinity.
|
||||
* - [DEFAULT]
|
||||
positive value is allowed.
|
||||
* - [filter_scheduler]
|
||||
- ``soft_anti_affinity_weight_multiplier``
|
||||
- Multiplier used for weighing hosts for group soft-anti-affinity. Only a
|
||||
positive value is meaningful. Negative means that the behavior will
|
||||
change to the opposite, which is soft-affinity.
|
||||
positive value is allowed.
|
||||
* - [filter_scheduler]
|
||||
- ``build_failure_weight_multiplier``
|
||||
- Multiplier used for weighing hosts which have recent build failures. A
|
||||
|
@ -443,15 +443,12 @@ The Filter Scheduler weighs hosts based on the config option
|
||||
* |ServerGroupSoftAffinityWeigher| The weigher can compute the weight based
|
||||
on the number of instances that run on the same server group. The largest
|
||||
weight defines the preferred host for the new instance. For the multiplier
|
||||
only a positive value is meaningful for the calculation as a negative value
|
||||
would mean that the affinity weigher would prefer non collocating placement.
|
||||
only a positive value is allowed for the calculation.
|
||||
|
||||
* |ServerGroupSoftAntiAffinityWeigher| The weigher can compute the weight based
|
||||
on the number of instances that run on the same server group as a negative
|
||||
value. The largest weight defines the preferred host for the new instance.
|
||||
For the multiplier only a positive value is meaningful for the calculation as
|
||||
a negative value would mean that the anti-affinity weigher would prefer
|
||||
collocating placement.
|
||||
For the multiplier only a positive value is allowed for the calculation.
|
||||
|
||||
* |BuildFailureWeigher| Weigh hosts by the number of recent failed boot attempts.
|
||||
It considers the build failure counter and can negatively weigh hosts with
|
||||
|
@ -467,10 +467,9 @@ Possible values:
|
||||
* A positive integer or float value, where the value corresponds to the
|
||||
multiplier ratio for this weigher.
|
||||
"""),
|
||||
# TODO(sfinucan): Add 'min' parameter and remove warning in 'affinity.py'
|
||||
cfg.FloatOpt("soft_affinity_weight_multiplier",
|
||||
default=1.0,
|
||||
deprecated_group="DEFAULT",
|
||||
min=0.0,
|
||||
help="""
|
||||
Multiplier used for weighing hosts for group soft-affinity.
|
||||
|
||||
@ -483,7 +482,7 @@ Possible values:
|
||||
cfg.FloatOpt(
|
||||
"soft_anti_affinity_weight_multiplier",
|
||||
default=1.0,
|
||||
deprecated_group="DEFAULT",
|
||||
min=0.0,
|
||||
help="""
|
||||
Multiplier used for weighing hosts for group soft-anti-affinity.
|
||||
|
||||
|
@ -54,40 +54,15 @@ class _SoftAffinityWeigherBase(weights.BaseHostWeigher):
|
||||
|
||||
class ServerGroupSoftAffinityWeigher(_SoftAffinityWeigherBase):
|
||||
policy_name = 'soft-affinity'
|
||||
warning_sent = False
|
||||
|
||||
def weight_multiplier(self):
|
||||
if (CONF.filter_scheduler.soft_affinity_weight_multiplier < 0 and
|
||||
not self.warning_sent):
|
||||
LOG.warning('For the soft_affinity_weight_multiplier only a '
|
||||
'positive value is meaningful as a negative value '
|
||||
'would mean that the affinity weigher would '
|
||||
'prefer non-collocating placement. Future '
|
||||
'versions of nova will restrict the config '
|
||||
'option to values >=0. Update your configuration '
|
||||
'file to mitigate future upgrade issues.')
|
||||
self.warning_sent = True
|
||||
|
||||
return CONF.filter_scheduler.soft_affinity_weight_multiplier
|
||||
|
||||
|
||||
class ServerGroupSoftAntiAffinityWeigher(_SoftAffinityWeigherBase):
|
||||
policy_name = 'soft-anti-affinity'
|
||||
warning_sent = False
|
||||
|
||||
def weight_multiplier(self):
|
||||
if (CONF.filter_scheduler.soft_anti_affinity_weight_multiplier < 0 and
|
||||
not self.warning_sent):
|
||||
LOG.warning('For the soft_anti_affinity_weight_multiplier '
|
||||
'only a positive value is meaningful as a '
|
||||
'negative value would mean that the anti-affinity '
|
||||
'weigher would prefer collocating placement. '
|
||||
'Future versions of nova will restrict the '
|
||||
'config option to values >=0. Update your '
|
||||
'configuration file to mitigate future upgrade '
|
||||
'issues.')
|
||||
self.warning_sent = True
|
||||
|
||||
return CONF.filter_scheduler.soft_anti_affinity_weight_multiplier
|
||||
|
||||
def _weigh_object(self, host_state, request_spec):
|
||||
|
@ -104,19 +104,6 @@ class SoftAffinityWeigherTestCase(SoftWeigherTestBase):
|
||||
expected_weight=2.0,
|
||||
expected_host='host2')
|
||||
|
||||
@mock.patch.object(affinity, 'LOG')
|
||||
def test_soft_affinity_weight_multiplier_negative_value(self, mock_log):
|
||||
self.flags(soft_affinity_weight_multiplier=-1.0,
|
||||
group='filter_scheduler')
|
||||
self._do_test(policy='soft-affinity',
|
||||
expected_weight=0.0,
|
||||
expected_host='host3')
|
||||
# call twice and assert that only one warning is emitted
|
||||
self._do_test(policy='soft-affinity',
|
||||
expected_weight=0.0,
|
||||
expected_host='host3')
|
||||
self.assertEqual(1, mock_log.warning.call_count)
|
||||
|
||||
|
||||
class SoftAntiAffinityWeigherTestCase(SoftWeigherTestBase):
|
||||
|
||||
@ -143,17 +130,3 @@ class SoftAntiAffinityWeigherTestCase(SoftWeigherTestBase):
|
||||
self._do_test(policy='soft-anti-affinity',
|
||||
expected_weight=2.0,
|
||||
expected_host='host3')
|
||||
|
||||
@mock.patch.object(affinity, 'LOG')
|
||||
def test_soft_anti_affinity_weight_multiplier_negative_value(self,
|
||||
mock_log):
|
||||
self.flags(soft_anti_affinity_weight_multiplier=-1.0,
|
||||
group='filter_scheduler')
|
||||
self._do_test(policy='soft-anti-affinity',
|
||||
expected_weight=0.0,
|
||||
expected_host='host2')
|
||||
# call twice and assert that only one warning is emitted
|
||||
self._do_test(policy='soft-anti-affinity',
|
||||
expected_weight=0.0,
|
||||
expected_host='host2')
|
||||
self.assertEqual(1, mock_log.warning.call_count)
|
||||
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
The ``[filter_scheduler]/soft_affinity_weight_multiplier`` and
|
||||
``[filter_scheduler]/soft_anti_affinity_weight_multiplier`` configuration
|
||||
options now have a hard minimum value of 0.0. Also, the deprecated alias
|
||||
to the ``[DEFAULT]`` group has been removed so the options must appear in
|
||||
the ``[filter_scheduler]`` group.
|
Loading…
Reference in New Issue
Block a user