Nir Soffer has uploaded a new change for review.

Change subject: storageServer: Avoid bogus warnings from createdir
......................................................................

storageServer: Avoid bogus warnings from createdir

When using fileUtils.createdir() and the directory already exists, a
bogus warning is logged. Since we are not specifying a mode, there is no
need to use this utility.

Now we use os.makedirs() directly and provide more useful logs.

Change-Id: I07db7b1af0b02901a338f649577291f9bc641057
Signed-off-by: Nir Soffer <[email protected]>
---
M vdsm/storage/storageServer.py
1 file changed, 11 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/36372/1

diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py
index de88ec4..d283d6c 100644
--- a/vdsm/storage/storageServer.py
+++ b/vdsm/storage/storageServer.py
@@ -203,17 +203,25 @@
         if self._mount.isMounted():
             return
 
-        fileUtils.createdir(self._getLocalPath())
+        mountpoint = self._getLocalPath()
+
+        self.log.debug("Creating mountpoint directory: %r", mountpoint)
+        try:
+            os.makedirs(mountpoint)
+        except OSError as e:
+            if e.errno != errno.EEXIST:
+                raise
+            self.log.debug("Using exisitng directory")
 
         try:
             self._mount.mount(self.options, self._vfsType)
         except MountError:
             t, v, tb = sys.exc_info()
             try:
-                os.rmdir(self._getLocalPath())
+                os.rmdir(mountpoint)
             except OSError:
                 self.log.warn("Error removing mountpoint directory: %r",
-                              self._getLocalPath())
+                              mountpoint)
             raise t, v, tb
         else:
             try:


-- 
To view, visit http://gerrit.ovirt.org/36372
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I07db7b1af0b02901a338f649577291f9bc641057
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to