Skip to content

Commit

Permalink
Touch in use image files when they're checked.
Browse files Browse the repository at this point in the history
It was intended that FLAGS.remove_unused_resized_minimum_age_seconds
would indicate the number of seconds a base file was unused before it
was removed. This however isn't true at the moment. Because instances
are COW mostly, this will be the time since the resize occurred,
which is normally instantly true once the image isn't being used any
more. This small patch corrects that by touching the base image during
check cycles which find it in use. Resolves bug 967845.

Change-Id: I75bf06cf758c9a2d7a8bde5ce67c789d7e299174
  • Loading branch information
mikalstill authored and vishvananda committed Mar 30, 2012
1 parent ada63db commit cd83d0a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nova/tests/test_imagecache.py
Expand Up @@ -562,6 +562,10 @@ def exists(path):

self.stubs.Set(os.path, 'exists', lambda x: exists(x))

# We need to stub utime as well
orig_utime = os.utime
self.stubs.Set(os, 'utime', lambda x, y: None)

# Fake up some instances in the instances directory
orig_listdir = os.listdir

Expand Down
2 changes: 2 additions & 0 deletions nova/virt/libvirt/imagecache.py
Expand Up @@ -349,6 +349,8 @@ def _handle_base_image(self, img_id, base_file):
LOG.debug(_('%(id)s (%(base_file)s): image is in use'),
{'id': img_id,
'base_file': base_file})
if os.path.exists(base_file):
os.utime(base_file, None)

def verify_base_images(self, context):
"""Verify that base images are in a reasonable state."""
Expand Down

0 comments on commit cd83d0a

Please sign in to comment.