New patch submitted by Yotam Oron (yoron(a)redhat.com)
You can review this change at:
http://gerrit.usersys.redhat.com/858
commit aaff596ebf15d43be91d2e87ead6b9b6664c575a
Author: Yotam Oron <yoron(a)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)))