diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-05-16 23:02:30 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-05-16 23:02:30 +0000 |
| commit | 7d1571bae1bd7c96f580965782e614b2be9efba0 (patch) | |
| tree | 0ec9568f51117b117324f0499652367d9d714598 /nova/compute | |
| parent | 5d90b39c36e8e8e1db82318e1d43129a8d2e1108 (diff) | |
| parent | 7b75fe7f571dd95287307f9d1138fb476a6bf721 (diff) | |
Merge "Optional timeout for servers stuck in build"
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/manager.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 9cb080dbe..8025a46a5 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -96,6 +96,11 @@ compute_opts = [ help="Automatically hard reboot an instance if it has been " "stuck in a rebooting state longer than N seconds. " "Set to 0 to disable."), + cfg.IntOpt("instance_build_timeout", + default=0, + help="Amount of time in seconds an instance can be in BUILD " + "before going into ERROR status." + "Set to 0 to disable."), cfg.IntOpt("rescue_timeout", default=0, help="Automatically unrescue an instance after N seconds. " @@ -450,6 +455,22 @@ class ComputeManager(manager.SchedulerDependentManager): with excutils.save_and_reraise_exception(): self._set_instance_error_state(context, instance_uuid) + @manager.periodic_task + def _check_instance_build_time(self, context): + """Ensure that instances are not stuck in build.""" + if FLAGS.instance_build_timeout == 0: + return + + filters = {'vm_state': vm_states.BUILDING} + building_insts = self.db.instance_get_all_by_filters(context, filters) + + for instance in building_insts: + if utils.is_older_than(instance['created_at'], + FLAGS.instance_build_timeout): + self._set_instance_error_state(context, instance['uuid']) + LOG.warn(_("Instance build timed out. Set to error state."), + instance=instance) + def _update_access_ip(self, context, instance, nw_info): """Update the access ip values for a given instance. |
