Use different timeouts for create and restore

Restoring an instance from a backup can take significantly longer than
just creating an instance. Introduce a new timeout for the restore case
with a higher default value

Change-Id: I44af03e9b2c966dd94fcfd0ff475f112ac21be5b
Closes-Bug: 1356645
This commit is contained in:
Nikhil Manchanda 2014-09-24 02:55:41 -07:00
parent 3cebe10518
commit 1654031cc6
3 changed files with 9 additions and 3 deletions

View File

@ -7,6 +7,8 @@ debug = True
# Update the service and instance statuses if the instances fails to become
# active within the configured usage_timeout.
# usage_timeout = 600
# restore_usage_timeout = 36000
update_status_on_fail = True
# The RabbitMQ broker address where a single node is used.

View File

@ -361,6 +361,9 @@ common_opts = [
cfg.IntOpt('usage_timeout', default=600,
help='Maximum time (in seconds) to wait for a Guest to become '
'active.'),
cfg.IntOpt('restore_usage_timeout', default=36000,
help='Maximum time (in seconds) to wait for a Guest instance '
'restored from a backup to become active.'),
cfg.IntOpt('cluster_usage_timeout', default=675,
help='Maximum time (in seconds) to wait for a cluster to '
'become active.'),

View File

@ -297,10 +297,11 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
# record to avoid over billing a customer for an instance that
# fails to build properly.
try:
usage_timeout = CONF.usage_timeout
timeout = (CONF.restore_usage_timeout if backup_info
else CONF.usage_timeout)
utils.poll_until(self._service_is_active,
sleep_time=USAGE_SLEEP_TIME,
time_out=usage_timeout)
time_out=timeout)
LOG.info(_("Created instance %s successfully.") % self.id)
self.send_usage_event('create', instance_size=flavor['ram'])
except PollTimeOut:
@ -357,7 +358,7 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
"from instance %(source)s "
"for new replica %(replica)s.") % {'source': slave_of_id,
'replica': self.id})
err = inst_models.InstanceTasks.BUILDING_ERROR_SLAVE
err = inst_models.InstanceTasks.BUILDING_ERROR_REPLICA
Backup.delete(context, snapshot_info['id'])
self._log_and_raise(e, msg, err)
except Exception: