unused images are always deleted (add to in-tree hper-v code)
This is to apply changes applied to openstack/computer-hyperv to the in-tree hyper-v code. Change-Id: Ib89c2e407bea5168f2eebb12cfb2d50e4566ff7a Closes-Bug: #1773342
This commit is contained in:
parent
a8e992b105
commit
716d17e054
@ -15,6 +15,7 @@
|
||||
|
||||
import os
|
||||
|
||||
import ddt
|
||||
import fixtures
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
@ -32,6 +33,7 @@ from nova.virt.hyperv import imagecache
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ImageCacheTestCase(test_base.HyperVBaseTestCase):
|
||||
"""Unit tests for the Hyper-V ImageCache class."""
|
||||
|
||||
@ -184,7 +186,10 @@ class ImageCacheTestCase(test_base.HyperVBaseTestCase):
|
||||
self.imagecache._vhdutils.get_vhd_info.assert_called_once_with(
|
||||
expected_vhd_path)
|
||||
|
||||
def test_age_and_verify_cached_images(self):
|
||||
@ddt.data(True, False)
|
||||
def test_age_and_verify_cached_images(self, remove_unused_base_images):
|
||||
self.flags(remove_unused_base_images=remove_unused_base_images)
|
||||
|
||||
fake_images = [mock.sentinel.FAKE_IMG1, mock.sentinel.FAKE_IMG2]
|
||||
fake_used_images = [mock.sentinel.FAKE_IMG1]
|
||||
|
||||
@ -201,8 +206,12 @@ class ImageCacheTestCase(test_base.HyperVBaseTestCase):
|
||||
|
||||
self.imagecache._update_image_timestamp.assert_called_once_with(
|
||||
mock.sentinel.FAKE_IMG1)
|
||||
self.imagecache._remove_if_old_image.assert_called_once_with(
|
||||
mock.sentinel.FAKE_IMG2)
|
||||
|
||||
if remove_unused_base_images:
|
||||
self.imagecache._remove_if_old_image.assert_called_once_with(
|
||||
mock.sentinel.FAKE_IMG2)
|
||||
else:
|
||||
self.imagecache._remove_if_old_image.assert_not_called()
|
||||
|
||||
@mock.patch.object(imagecache.os, 'utime')
|
||||
@mock.patch.object(imagecache.ImageCache, '_get_image_backing_files')
|
||||
|
@ -171,7 +171,7 @@ class ImageCache(imagecache.ImageCacheManager):
|
||||
# change the timestamp on the image so as to reflect the last
|
||||
# time it was used
|
||||
self._update_image_timestamp(img)
|
||||
else:
|
||||
elif CONF.remove_unused_base_images:
|
||||
self._remove_if_old_image(img)
|
||||
|
||||
def _update_image_timestamp(self, image):
|
||||
|
8
releasenotes/notes/bug-1773342-52b6a1460c7bee64.yaml
Normal file
8
releasenotes/notes/bug-1773342-52b6a1460c7bee64.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes `bug 1773342`_ where the Hyper-v driver always deleted unused images
|
||||
ignoring ``remove_unused_images`` config option. This change will now allow
|
||||
deployers to disable the auto-removal of old images.
|
||||
|
||||
.. _bug 1773342: https://bugs.launchpad.net/nova/+bug/1773342
|
Loading…
Reference in New Issue
Block a user