Merge "Expose shutdown retry interval as config setting"

This commit is contained in:
Zuul 2018-04-11 16:41:42 +00:00 committed by Gerrit Code Review
commit 5244d25f89
5 changed files with 44 additions and 8 deletions

@ -490,11 +490,6 @@ class ComputeManager(manager.Manager):
target = messaging.Target(version='5.0')
# How long to wait in seconds before re-issuing a shutdown
# signal to an instance during power off. The overall
# time to wait is set by CONF.shutdown_timeout.
SHUTDOWN_RETRY_INTERVAL = 10
def __init__(self, compute_driver=None, *args, **kwargs):
"""Load configuration options and connect to the hypervisor."""
self.virtapi = ComputeVirtAPI(self)
@ -2310,7 +2305,7 @@ class ComputeManager(manager.Manager):
timeout = compute_utils.get_value_from_system_metadata(instance,
key='image_os_shutdown_timeout', type=int,
default=CONF.shutdown_timeout)
retry_interval = self.SHUTDOWN_RETRY_INTERVAL
retry_interval = CONF.compute.shutdown_retry_interval
else:
timeout = 0
retry_interval = 0

@ -643,6 +643,23 @@ Possible values:
* Any positive integer representing a build failure count.
* Zero to never auto-disable.
"""),
cfg.IntOpt("shutdown_retry_interval",
default=10,
min=1,
help="""
Time to wait in seconds before resending an ACPI shutdown signal to
instances.
The overall time to wait is set by ``shutdown_timeout``.
Possible values:
* Any integer greater than 0 in seconds
Related options:
* ``shutdown_timeout``
""")
]
interval_opts = [

@ -1253,6 +1253,24 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
mock_instance_save.assert_called_once_with()
self.assertIsNone(instance.task_state)
@mock.patch('nova.virt.fake.FakeDriver.power_off')
@mock.patch.object(compute_utils, 'get_value_from_system_metadata',
return_value=CONF.shutdown_timeout)
def test_power_off_values(self, mock_get_metadata, mock_power_off):
self.flags(shutdown_retry_interval=20, group='compute')
instance = fake_instance.fake_instance_obj(
self.context,
uuid=uuids.instance,
vm_state=vm_states.ACTIVE,
task_state=task_states.POWERING_OFF)
self.compute._power_off_instance(
self.context, instance,
clean_shutdown=True)
mock_power_off.assert_called_once_with(
instance,
CONF.shutdown_timeout,
20)
@mock.patch('nova.context.RequestContext.elevated')
@mock.patch('nova.objects.Instance.get_network_info')
@mock.patch(

@ -141,7 +141,7 @@ class ShelveComputeManagerTestCase(test_compute.BaseTestCase):
if clean_shutdown:
mock_power_off_call_list.append(
mock.call(instance, CONF.shutdown_timeout,
self.compute.SHUTDOWN_RETRY_INTERVAL))
CONF.compute.shutdown_retry_interval))
else:
mock_power_off_call_list.append(mock.call(instance, 0, 0))
@ -183,7 +183,7 @@ class ShelveComputeManagerTestCase(test_compute.BaseTestCase):
def test_shelve_offload(self, mock_power_off):
instance = self._shelve_offload()
mock_power_off.assert_called_once_with(instance,
CONF.shutdown_timeout, self.compute.SHUTDOWN_RETRY_INTERVAL)
CONF.shutdown_timeout, CONF.compute.shutdown_retry_interval)
@mock.patch.object(nova.virt.fake.SmallFakeDriver, 'power_off')
def test_shelve_offload_forced_shutdown(self, mock_power_off):

@ -0,0 +1,6 @@
---
features:
- |
The shutdown retry interval in powering off instances can now be set using
the configuration setting ``shutdown_retry_interval``, in the
compute configuration group.