summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-08-10 01:10:01 +0000
committerGerrit Code Review <review@openstack.org>2022-08-10 01:10:01 +0000
commitf8f83811c42138c943989510548fe24cc71c88f9 (patch)
treee92515dad197b52c77f3cdd860bd189d841ecad9
parent3058994fc017e46a4be8069dcfff1c460acc6d0f (diff)
parente48c62187ca15e130c35b421e5e311eea9a334db (diff)
downloadironic-f8f83811c42138c943989510548fe24cc71c88f9.tar.gz
Merge "Log successful clean up in image cache"
-rw-r--r--ironic/drivers/modules/image_cache.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/ironic/drivers/modules/image_cache.py b/ironic/drivers/modules/image_cache.py
index 17dfba9cf..5ca053f36 100644
--- a/ironic/drivers/modules/image_cache.py
+++ b/ironic/drivers/modules/image_cache.py
@@ -237,6 +237,7 @@ class ImageCache(object):
"""
threshold = time.time() - self._cache_ttl
survived = []
+ count = 0
for file_name, last_used, stat in listing:
if last_used < threshold:
try:
@@ -246,6 +247,7 @@ class ImageCache(object):
"master image cache: %(exc)s",
{'name': file_name, 'exc': exc})
else:
+ count += 1
if amount is not None:
amount -= stat.st_size
if amount <= 0:
@@ -253,6 +255,9 @@ class ImageCache(object):
break
else:
survived.append((file_name, last_used, stat))
+ if count:
+ LOG.debug('Removed %(count)d expired file(s) from %(dir)s',
+ {'count': count, 'dir': self.master_dir})
return survived, amount
def _clean_up_ensure_cache_size(self, listing, amount):
@@ -275,6 +280,7 @@ class ImageCache(object):
for f in os.listdir(self.master_dir))
total_size = sum(os.path.getsize(f)
for f in total_listing)
+ count = 0
while listing and (total_size > self._cache_size
or (amount is not None and amount > 0)):
file_name, last_used, stat = listing.pop()
@@ -286,6 +292,7 @@ class ImageCache(object):
{'name': file_name, 'exc': exc})
else:
total_size -= stat.st_size
+ count += 1
if amount is not None:
amount -= stat.st_size
@@ -295,6 +302,10 @@ class ImageCache(object):
"threshold %(expected)d",
{'dir': self.master_dir, 'actual': total_size,
'expected': self._cache_size})
+ elif count:
+ LOG.debug(
+ 'Removed %(count)d file(s) from %(dir)s to free up space',
+ {'count': count, 'dir': self.master_dir})
return max(amount, 0) if amount is not None else 0