diff --git a/nova/flags.py b/nova/flags.py index cf02c971..f89e5379 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -464,3 +464,6 @@ DEFINE_integer('zombie_instance_updated_at_window', 172800, 'being cleaned up.') DEFINE_boolean('allow_ec2_admin_api', False, 'Enable/Disable EC2 Admin API') + +DEFINE_integer('service_down_time', 60, + 'maximum time since last check-in for up service') diff --git a/nova/scheduler/simple.py b/nova/scheduler/simple.py index fb800756..52f6be3b 100644 --- a/nova/scheduler/simple.py +++ b/nova/scheduler/simple.py @@ -26,6 +26,7 @@ from nova import flags from nova import exception from nova.scheduler import driver from nova.scheduler import chance +from nova import utils FLAGS = flags.FLAGS flags.DEFINE_integer("max_cores", 16, @@ -57,7 +58,7 @@ class SimpleScheduler(chance.ChanceScheduler): if host and context.is_admin: service = db.service_get_by_args(elevated, host, 'nova-compute') - if not self.service_is_up(service): + if not utils.service_is_up(service): raise exception.WillNotSchedule(host=host) return host @@ -79,7 +80,7 @@ class SimpleScheduler(chance.ChanceScheduler): instance_cores + instance_opts['vcpus'] > FLAGS.max_cores: msg = _("Not enough allocatable CPU cores remaining") raise exception.NoValidHost(reason=msg) - if self.service_is_up(service): + if utils.service_is_up(service) and not service['disabled']: return service['host'] msg = _("Is the appropriate service running?") raise exception.NoValidHost(reason=msg) @@ -120,7 +121,7 @@ class SimpleScheduler(chance.ChanceScheduler): zone, _x, host = availability_zone.partition(':') if host and context.is_admin: service = db.service_get_by_args(elevated, host, 'nova-volume') - if not self.service_is_up(service): + if not utils.service_is_up(service): raise exception.WillNotSchedule(host=host) driver.cast_to_volume_host(context, host, 'create_volume', volume_id=volume_id, **_kwargs) @@ -135,7 +136,7 @@ class SimpleScheduler(chance.ChanceScheduler): if volume_gigabytes + volume_ref['size'] > FLAGS.max_gigabytes: msg = _("Not enough allocatable volume gigabytes remaining") raise exception.NoValidHost(reason=msg) - if self.service_is_up(service): + if utils.service_is_up(service) and not service['disabled']: driver.cast_to_volume_host(context, service['host'], 'create_volume', volume_id=volume_id, **_kwargs) return None diff --git a/nova/scheduler/vsa.py b/nova/scheduler/vsa.py index dd17b19c..7b45e93e 100644 --- a/nova/scheduler/vsa.py +++ b/nova/scheduler/vsa.py @@ -215,7 +215,7 @@ class VsaScheduler(simple.SimpleScheduler): zone, _x, host = availability_zone.partition(':') service = db.service_get_by_args(context.elevated(), host, 'nova-volume') - if not self.service_is_up(service): + if service['disabled'] or not utils.service_is_up(service): raise exception.WillNotSchedule(host=host) return host diff --git a/nova/tests/scheduler/test_vsa_scheduler.py b/nova/tests/scheduler/test_vsa_scheduler.py index cc141897..a7cd2358 100644 --- a/nova/tests/scheduler/test_vsa_scheduler.py +++ b/nova/tests/scheduler/test_vsa_scheduler.py @@ -197,7 +197,7 @@ class VsaSchedulerTestCase(test.TestCase): scheduled_volume = {'id': volume_id, 'host': values['host']} def _fake_service_get_by_args(self, context, host, binary): - return "service" + return {'host': 'fake_host', 'disabled': False} def _fake_service_is_up_True(self, service): return True @@ -386,7 +386,7 @@ class VsaSchedulerTestCase(test.TestCase): self.stubs.Set(nova.db, 'service_get_by_args', self._fake_service_get_by_args) - self.stubs.Set(self.sched, + self.stubs.Set(utils, 'service_is_up', self._fake_service_is_up_False) self.assertRaises(exception.WillNotSchedule, @@ -395,7 +395,7 @@ class VsaSchedulerTestCase(test.TestCase): request_spec, availability_zone="nova:host_5") - self.stubs.Set(self.sched, + self.stubs.Set(utils, 'service_is_up', self._fake_service_is_up_True) self.sched.schedule_create_volumes(self.context, @@ -462,7 +462,7 @@ class VsaSchedulerTestCase(test.TestCase): self.stubs.Set(nova.db, 'volume_get', _fake_volume_get_az) self.stubs.Set(nova.db, 'service_get_by_args', self._fake_service_get_by_args) - self.stubs.Set(self.sched, + self.stubs.Set(utils, 'service_is_up', self._fake_service_is_up_True) self.sched.schedule_create_volume(self.context,