Merge "Do not try to create temporary URLs with zero lifetime"

This commit is contained in:
Zuul 2019-04-17 15:38:29 +00:00 committed by Gerrit Code Review
commit a03e55f2d4
4 changed files with 73 additions and 1 deletions

View File

@ -3609,7 +3609,10 @@ def _store_configdrive(node, configdrive):
if CONF.deploy.configdrive_use_object_store:
# NOTE(lucasagomes): No reason to use a different timeout than
# the one used for deploying the node
timeout = CONF.conductor.deploy_callback_timeout
timeout = (CONF.conductor.configdrive_swift_temp_url_duration
or CONF.conductor.deploy_callback_timeout
# The documented default in ironic.conf.conductor
or 1800)
container = CONF.conductor.configdrive_swift_container
object_name = _get_configdrive_obj_name(node)

View File

@ -149,6 +149,13 @@ opts = [
help=_('Name of the Swift container to store config drive '
'data. Used when configdrive_use_object_store is '
'True.')),
cfg.IntOpt('configdrive_swift_temp_url_duration',
min=60,
help=_('The timeout (in seconds) after which a configdrive '
'temporary URL becomes invalid. Defaults to '
'deploy_callback_timeout if it is set, otherwise to '
'1800 seconds. Used when '
'configdrive_use_object_store is True.')),
cfg.IntOpt('inspect_wait_timeout',
default=1800,
help=_('Timeout (seconds) for waiting for node inspection. '

View File

@ -7548,6 +7548,61 @@ class StoreConfigDriveTestCase(db_base.DbTestCase):
self.node.refresh()
self.assertEqual(expected_instance_info, self.node.instance_info)
def test_store_configdrive_swift_no_deploy_timeout(self, mock_swift):
container_name = 'foo_container'
expected_obj_name = 'configdrive-%s' % self.node.uuid
expected_obj_header = {'X-Delete-After': '1200'}
expected_instance_info = {'configdrive': 'http://1.2.3.4'}
# set configs and mocks
CONF.set_override('configdrive_use_object_store', True,
group='deploy')
CONF.set_override('configdrive_swift_container', container_name,
group='conductor')
CONF.set_override('configdrive_swift_temp_url_duration', 1200,
group='conductor')
CONF.set_override('deploy_callback_timeout', 0,
group='conductor')
mock_swift.return_value.get_temp_url.return_value = 'http://1.2.3.4'
manager._store_configdrive(self.node, b'foo')
mock_swift.assert_called_once_with()
mock_swift.return_value.create_object.assert_called_once_with(
container_name, expected_obj_name, mock.ANY,
object_headers=expected_obj_header)
mock_swift.return_value.get_temp_url.assert_called_once_with(
container_name, expected_obj_name, 1200)
self.node.refresh()
self.assertEqual(expected_instance_info, self.node.instance_info)
def test_store_configdrive_swift_no_deploy_timeout_fallback(self,
mock_swift):
container_name = 'foo_container'
expected_obj_name = 'configdrive-%s' % self.node.uuid
expected_obj_header = {'X-Delete-After': '1800'}
expected_instance_info = {'configdrive': 'http://1.2.3.4'}
# set configs and mocks
CONF.set_override('configdrive_use_object_store', True,
group='deploy')
CONF.set_override('configdrive_swift_container', container_name,
group='conductor')
CONF.set_override('deploy_callback_timeout', 0,
group='conductor')
mock_swift.return_value.get_temp_url.return_value = 'http://1.2.3.4'
manager._store_configdrive(self.node, b'foo')
mock_swift.assert_called_once_with()
mock_swift.return_value.create_object.assert_called_once_with(
container_name, expected_obj_name, mock.ANY,
object_headers=expected_obj_header)
mock_swift.return_value.get_temp_url.assert_called_once_with(
container_name, expected_obj_name, 1800)
self.node.refresh()
self.assertEqual(expected_instance_info, self.node.instance_info)
@mgr_utils.mock_record_keepalive
class NodeInspectHardware(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):

View File

@ -0,0 +1,7 @@
---
fixes:
- |
No longer tries to create a temporary URL with zero lifetime if the
``deploy_callback_timeout`` option is set to zero. The default of 1800
seconds is used in that case. Use the new
``configdrive_swift_temp_url_duration`` option to override.