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

Dan Kenigsberg danken at redhat.com
Mon Sep 5 15:16:50 UTC 2011


New patch submitted by Dan Kenigsberg (danken at redhat.com)

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

commit acdc6d99826dc9ed6d3965cb304095d472da47be
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 a77be87..aa4d6aa 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -276,7 +276,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