Merge "Allow disabling TFTP image cache"
This commit is contained in:
commit
68832e8340
ironic
releasenotes/notes
@ -925,8 +925,9 @@ def prepare_instance_pxe_config(task, image_info,
|
|||||||
@image_cache.cleanup(priority=25)
|
@image_cache.cleanup(priority=25)
|
||||||
class TFTPImageCache(image_cache.ImageCache):
|
class TFTPImageCache(image_cache.ImageCache):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
master_path = CONF.pxe.tftp_master_path or None
|
||||||
super(TFTPImageCache, self).__init__(
|
super(TFTPImageCache, self).__init__(
|
||||||
CONF.pxe.tftp_master_path,
|
master_path,
|
||||||
# MiB -> B
|
# MiB -> B
|
||||||
cache_size=CONF.pxe.image_cache_size * 1024 * 1024,
|
cache_size=CONF.pxe.image_cache_size * 1024 * 1024,
|
||||||
# min -> sec
|
# min -> sec
|
||||||
|
@ -76,7 +76,7 @@ opts = [
|
|||||||
default='/tftpboot/master_images',
|
default='/tftpboot/master_images',
|
||||||
help=_('On ironic-conductor node, directory where master TFTP '
|
help=_('On ironic-conductor node, directory where master TFTP '
|
||||||
'images are stored on disk. '
|
'images are stored on disk. '
|
||||||
'Setting to <None> disables image caching.')),
|
'Setting to the empty string disables image caching.')),
|
||||||
cfg.IntOpt('dir_permission',
|
cfg.IntOpt('dir_permission',
|
||||||
help=_("The permission that will be applied to the TFTP "
|
help=_("The permission that will be applied to the TFTP "
|
||||||
"folders upon creation. This should be set to the "
|
"folders upon creation. This should be set to the "
|
||||||
|
@ -1740,3 +1740,29 @@ class CleanUpPxeEnvTestCase(db_base.DbTestCase):
|
|||||||
mock_pxe_clean.assert_called_once_with(task, ipxe_enabled=False)
|
mock_pxe_clean.assert_called_once_with(task, ipxe_enabled=False)
|
||||||
mock_unlink.assert_any_call('deploy_kernel')
|
mock_unlink.assert_any_call('deploy_kernel')
|
||||||
mock_cache.return_value.clean_up.assert_called_once_with()
|
mock_cache.return_value.clean_up.assert_called_once_with()
|
||||||
|
|
||||||
|
|
||||||
|
class TFTPImageCacheTestCase(db_base.DbTestCase):
|
||||||
|
@mock.patch.object(fileutils, 'ensure_tree')
|
||||||
|
def test_with_master_path(self, mock_ensure_tree):
|
||||||
|
self.config(tftp_master_path='/fake/path', group='pxe')
|
||||||
|
self.config(image_cache_size=500, group='pxe')
|
||||||
|
self.config(image_cache_ttl=30, group='pxe')
|
||||||
|
|
||||||
|
cache = pxe_utils.TFTPImageCache()
|
||||||
|
|
||||||
|
mock_ensure_tree.assert_called_once_with('/fake/path')
|
||||||
|
self.assertEqual(500 * 1024 * 1024, cache._cache_size)
|
||||||
|
self.assertEqual(30 * 60, cache._cache_ttl)
|
||||||
|
|
||||||
|
@mock.patch.object(fileutils, 'ensure_tree')
|
||||||
|
def test_without_master_path(self, mock_ensure_tree):
|
||||||
|
self.config(tftp_master_path='', group='pxe')
|
||||||
|
self.config(image_cache_size=500, group='pxe')
|
||||||
|
self.config(image_cache_ttl=30, group='pxe')
|
||||||
|
|
||||||
|
cache = pxe_utils.TFTPImageCache()
|
||||||
|
|
||||||
|
mock_ensure_tree.assert_not_called()
|
||||||
|
self.assertEqual(500 * 1024 * 1024, cache._cache_size)
|
||||||
|
self.assertEqual(30 * 60, cache._cache_ttl)
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes an issue where the master TFTP image cache could not be disbled.
|
||||||
|
The configuration option ``[pxe]/tftp_master_path`` may now be set to
|
||||||
|
the empty string to disable the cache. For more information, see
|
||||||
|
story `2004608 <https://storyboard.openstack.org/#!/story/2004608>`_.
|
Loading…
x
Reference in New Issue
Block a user