Fix image cache db query when limits are enabled

We were missing the context parameter... and apparently
never tested with cache limits enabled. This fixes
it and updates the unit tests to check for it too.

I'll follow up with a devstack patch to set some
limits by default too so we cover more of this
code and have it behave like a production deployment
in gate jobs.

Change-Id: Ia6d43b35843682bd201e57bb2941ca0243606412
Closes-Bug: #1701696
(cherry picked from commit 70719d028a)
This commit is contained in:
Patrick East 2017-06-30 11:21:51 -07:00 committed by Eric Harney
parent 81ccd589b7
commit 7246988316
2 changed files with 3 additions and 0 deletions

View File

@ -134,6 +134,7 @@ class ImageVolumeCache(object):
# Assume the entries are ordered by most recently used to least used.
entries = self.db.image_volume_cache_get_all(
context,
**self._get_query_filters(volume))
current_count = len(entries)

View File

@ -254,6 +254,8 @@ class ImageVolumeCacheTestCase(test.TestCase):
self.assertEqual(2, mock_delete.call_count)
mock_delete.assert_any_call(self.context, entry2)
mock_delete.assert_any_call(self.context, entry3)
self.mock_db.image_volume_cache_get_all.assert_called_with(
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)