[NEW PATCH] BZ#733910 - Clean links in directories in __cleanStorageRepository (via gerrit-bot)

Yotam Oron yoron at redhat.com
Sun Aug 28 14:22:32 UTC 2011


New patch submitted by Yotam Oron (yoron at redhat.com)

You can review this change at: http://gerrit.usersys.redhat.com/858

commit aaff596ebf15d43be91d2e87ead6b9b6664c575a
Author: Yotam Oron <yoron at redhat.com>
Date:   Sun Aug 28 17:23:02 2011 +0300

    BZ#733910 - Clean links in directories in __cleanStorageRepository
    
    os.walk() sees links to directories as directories, so the code
    tries to delete the links with rmdir(), fails, and then the consequent
    rmdir() of the parent dir also fails since the directory is not empty.
    Instead of rmdir(), unlink() a link.
    
    Change-Id: I0bd54dcca2b73f0f371aae4d6952a0da137c25db

diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index f83316c..7975a72 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -277,7 +277,11 @@ class HSM:
 
         for directory in rmDirList:
             try:
-                os.rmdir(directory)
+                # os.walk() can see a link to a directory as a directory
+                if os.path.islink(directory):
+                    os.unlink(directory)
+                else:
+                    os.rmdir(directory)
             except Exception, ex:
                 self.log.warn("Could not delete dir '%s' (%s: %s)." % (fullPath, ex.__class__.__name__, str(ex)))
 




More information about the vdsm-patches mailing list