From 37d1c1d83ca7b6cc811c9fbf9e7012d54bc271bb Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Wed, 22 Aug 2012 09:12:15 -0700 Subject: [PATCH] Remove partial image data when filesystem is full When an image is uploaded that fills up the local filesystem, attempt to delete the created file. This only applies to the 'filesystem' store driver. Fixes bug 1019421 Change-Id: Ie12d736f3efb29b0862fef2899a1d2c142def38e --- glance/store/filesystem.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/glance/store/filesystem.py b/glance/store/filesystem.py index 3fa229a0..b4055b82 100644 --- a/glance/store/filesystem.py +++ b/glance/store/filesystem.py @@ -210,6 +210,11 @@ class Store(glance.store.base.Store): f.write(buf) except IOError as e: if e.errno in [errno.EFBIG, errno.ENOSPC]: + try: + os.unlink(filepath) + except Exception: + msg = _('Unable to remove partial image data for image %s') + LOG.error(msg % image_id) raise exception.StorageFull() elif e.errno == errno.EACCES: raise exception.StorageWriteDenied()