Scheduler: enforce max attempts at service startup

The CFG module now supports min and max values. This is validated
when the configuration file is read. This change enables us to do
the validation of the 'scheduler_max_attempts' at init rather
than when an instance is being booted.

TrivialFix

Change-Id: Id44fa9299d509a61f586e843cac485a00f2af032
This commit is contained in:
Gary Kotton
2016-01-10 06:50:39 -08:00
parent f1da349a4f
commit 7954a7e1ce
4 changed files with 5 additions and 22 deletions

View File

@@ -82,15 +82,6 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
for weighed_host in weighed_hosts:
self.assertIsNotNone(weighed_host.obj)
def test_max_attempts(self):
self.flags(scheduler_max_attempts=4)
self.assertEqual(4, scheduler_utils._max_attempts())
def test_invalid_max_attempts(self):
self.flags(scheduler_max_attempts=0)
self.assertRaises(exception.NovaException,
scheduler_utils._max_attempts)
def test_add_retry_host(self):
retry = dict(num_attempts=1, hosts=[])
filter_properties = dict(retry=retry)

View File

@@ -187,9 +187,8 @@ class SchedulerUtilsTestCase(test.NoDBTestCase):
self._test_populate_filter_props(force_nodes=['force-node1',
'force-node2'])
@mock.patch.object(scheduler_utils, '_max_attempts')
def test_populate_retry_exception_at_max_attempts(self, _max_attempts):
_max_attempts.return_value = 2
def test_populate_retry_exception_at_max_attempts(self):
self.flags(scheduler_max_attempts=2)
msg = 'The exception text was preserved!'
filter_properties = dict(retry=dict(num_attempts=2, hosts=[],
exc_reason=[msg]))