Idan Shaby has uploaded a new change for review.

Change subject: fileSD: improve error handling in deleteImage
......................................................................

fileSD: improve error handling in deleteImage

In FileStorageDomainManifest.deleteImage, we used to log that the volume
could not be removed even if it was removed but the meta/lease file
could not be removed afterwards.

This patch logs more informative errors about the specific file that
could not be removed. If the removal fails because the file doesn't
exist, we log a warning. Otherwise, we log an error message that the
file can't be removed.

Also, if one of the files couldn't be removed, we didn't try to remove
the others.  Now we handle each removal separately, so that a failure in
the removal of one file doesn't affect the removal of the others.

Bug-Url: https://bugzilla.redhat.com/1292092
Change-Id: I9eeb28a70f708a4f9a5effe4ff294da63b757369
Signed-off-by: Idan Shaby <ish...@redhat.com>
---
M vdsm/storage/fileSD.py
1 file changed, 14 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/29/51229/1

diff --git a/vdsm/storage/fileSD.py b/vdsm/storage/fileSD.py
index ec46d18..9deabf3 100644
--- a/vdsm/storage/fileSD.py
+++ b/vdsm/storage/fileSD.py
@@ -395,18 +395,10 @@
             raise se.ImageDeleteError("%s %s" % (imgUUID, str(e)))
         for volUUID in volsImgs:
             volPath = os.path.join(toDelDir, volUUID)
-            try:
-                self.log.debug("Removing file: %s", volPath)
-                self.oop.os.remove(volPath)
-                metaFile = volPath + '.meta'
-                self.log.debug("Removing file: %s", metaFile)
-                self.oop.os.remove(metaFile)
-                leaseFile = volPath + '.lease'
-                self.log.debug("Removing file: %s", leaseFile)
-                self.oop.os.remove(leaseFile)
-            except OSError:
-                self.log.error("vol: %s can't be removed.",
-                               volPath, exc_info=True)
+            self._deleteVolumeFile(volPath)
+            self._deleteVolumeFile(volPath + '.meta')
+            if self.hasVolumeLeases():
+                self._deleteVolumeFile(volPath + '.lease')
         self.log.debug("Removing directory: %s", toDelDir)
         try:
             self.oop.os.rmdir(toDelDir)
@@ -414,6 +406,16 @@
             self.log.error("removed image dir: %s can't be removed", toDelDir)
             raise se.ImageDeleteError("%s %s" % (imgUUID, str(e)))
 
+    def _deleteVolumeFile(self, path):
+        self.log.debug("Removing file: %s", path)
+        try:
+            self.oop.os.remove(path)
+        except OSError as e:
+            if e.errno == errno.ENOENT:
+                self.log.warning("File %r does not exist: %s", path, e)
+            else:
+                self.log.error("File %r cannot be removed: %s", path, e)
+
     def zeroImage(self, sdUUID, imgUUID, volsImgs):
         self.log.warning("image %s on a fileSD %s won't be zeroed." %
                          (imgUUID, sdUUID))


-- 
To view, visit https://gerrit.ovirt.org/51229
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9eeb28a70f708a4f9a5effe4ff294da63b757369
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Idan Shaby <ish...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to