From 313becd5ffac3fd7c9a41d34134ee66d9a145228 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Thu, 3 Jan 2019 10:34:18 -0500 Subject: [PATCH] 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 --- doc/source/admin/configuration/schedulers.rst | 10 +++---- doc/source/user/filter-scheduler.rst | 7 ++--- nova/conf/scheduler.py | 5 ++-- nova/scheduler/weights/affinity.py | 25 ----------------- .../weights/test_weights_affinity.py | 27 ------------------- ...t-multiplier-cleanup-fed9ec25660befd3.yaml | 8 ++++++ 6 files changed, 16 insertions(+), 66 deletions(-) create mode 100644 releasenotes/notes/stein-affinity-weight-multiplier-cleanup-fed9ec25660befd3.yaml diff --git a/doc/source/admin/configuration/schedulers.rst b/doc/source/admin/configuration/schedulers.rst index bed37c670831..0bbded5dd768 100644 --- a/doc/source/admin/configuration/schedulers.rst +++ b/doc/source/admin/configuration/schedulers.rst @@ -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 diff --git a/doc/source/user/filter-scheduler.rst b/doc/source/user/filter-scheduler.rst index a126a696bef7..91b0b64130d1 100644 --- a/doc/source/user/filter-scheduler.rst +++ b/doc/source/user/filter-scheduler.rst @@ -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 diff --git a/nova/conf/scheduler.py b/nova/conf/scheduler.py index b5513758f312..ada6495ca5f0 100644 --- a/nova/conf/scheduler.py +++ b/nova/conf/scheduler.py @@ -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. diff --git a/nova/scheduler/weights/affinity.py b/nova/scheduler/weights/affinity.py index 90297f51a4dc..71f16ac9bb64 100644 --- a/nova/scheduler/weights/affinity.py +++ b/nova/scheduler/weights/affinity.py @@ -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): diff --git a/nova/tests/unit/scheduler/weights/test_weights_affinity.py b/nova/tests/unit/scheduler/weights/test_weights_affinity.py index 795bc519da53..dc953dde65aa 100644 --- a/nova/tests/unit/scheduler/weights/test_weights_affinity.py +++ b/nova/tests/unit/scheduler/weights/test_weights_affinity.py @@ -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) diff --git a/releasenotes/notes/stein-affinity-weight-multiplier-cleanup-fed9ec25660befd3.yaml b/releasenotes/notes/stein-affinity-weight-multiplier-cleanup-fed9ec25660befd3.yaml new file mode 100644 index 000000000000..2a7fb7da0648 --- /dev/null +++ b/releasenotes/notes/stein-affinity-weight-multiplier-cleanup-fed9ec25660befd3.yaml @@ -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.