Fix image volume cache max size and max count limits
Fix the code that enforces the image volume cache max size and max count limits so that each limit functions independently from the other. This fixes a bug where the code would function correctly when both were set to zero (unlimited) or when both limits were set (non-zero), but would misbehave when only one limit was set and the other unlimited. Closes-Bug: #1792944 Change-Id: I8b4843c2e9392139b42d6e2ebd2c5e1cd09d4c7a
This commit is contained in:
parent
f5712758a0
commit
74249de639
@ -155,8 +155,10 @@ class ImageVolumeCache(object):
|
||||
'count': current_count,
|
||||
'max_count': self.max_cache_size_count})
|
||||
|
||||
while ((current_size > self.max_cache_size_gb
|
||||
or current_count > self.max_cache_size_count)
|
||||
while (((current_size > self.max_cache_size_gb and
|
||||
self.max_cache_size_gb > 0)
|
||||
or (current_count > self.max_cache_size_count and
|
||||
self.max_cache_size_count > 0))
|
||||
and len(entries)):
|
||||
entry = entries.pop()
|
||||
LOG.debug('Reclaiming image-volume cache space; removing cache '
|
||||
|
@ -236,7 +236,7 @@ class ImageVolumeCacheTestCase(test.TestCase):
|
||||
self.assertFalse(has_space)
|
||||
|
||||
def test_ensure_space_need_gb(self):
|
||||
cache = self._build_cache(max_gb=30, max_count=10)
|
||||
cache = self._build_cache(max_gb=30, max_count=0)
|
||||
mock_delete = mock.patch.object(cache, '_delete_image_volume').start()
|
||||
|
||||
entries = []
|
||||
@ -258,7 +258,7 @@ class ImageVolumeCacheTestCase(test.TestCase):
|
||||
self.context, cluster_name=self.volume_ovo.cluster_name)
|
||||
|
||||
def test_ensure_space_need_count(self):
|
||||
cache = self._build_cache(max_gb=30, max_count=2)
|
||||
cache = self._build_cache(max_gb=0, max_count=2)
|
||||
mock_delete = mock.patch.object(cache, '_delete_image_volume').start()
|
||||
|
||||
entries = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user