Sandro Bonazzola has uploaded a new change for review.

Change subject: packaging: setup: handle unmount with busy storage
......................................................................

packaging: setup: handle unmount with busy storage

avoid to exit immediately if unmount fails for some reason
like Device or resource busy while validating the storage
location. Try to unmount the storage for a few times before
giving up.

Change-Id: I71e78ccab0c25efcd9521938ae3494799786f3d7
Signed-off-by: Sandro Bonazzola <[email protected]>
---
M src/plugins/ovirt-hosted-engine-setup/storage/storage.py
1 file changed, 26 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/73/17873/1

diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py 
b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
index a68b2f6..ca103c5 100644
--- a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
+++ b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
@@ -26,6 +26,7 @@
 import uuid
 import gettext
 import tempfile
+import time
 
 
 from otopi import util
@@ -50,6 +51,7 @@
     GLUSTERFS_DOMAIN = 7
 
     DATA_DOMAIN = 1
+    UMOUNT_TRIES = 10
 
     def __init__(self, context):
         super(Plugin, self).__init__(context=context)
@@ -75,13 +77,22 @@
         )
 
     def _umount(self, path):
-        self.execute(
-            (
-                self.command.get('umount'),
-                path
-            ),
-            raiseOnError=False
-        )
+        rc = -1
+        tries = self.UMOUNT_TRIES
+        while tries > 0:
+            rc, _stdout, _stderr = self.execute(
+                (
+                    self.command.get('umount'),
+                    path
+                ),
+                raiseOnError=False
+            )
+            if rc == 0:
+                tries = -1
+            else:
+                tries -= 1
+                time.sleep(1)
+        return rc
 
     def _handleHostId(self):
         if not self.environment[
@@ -174,8 +185,14 @@
                 ohostedcons.Const.MINIMUM_SPACE_STORAGEDOMAIN_MB
             )
         finally:
-            self._umount(path)
-            os.rmdir(path)
+            if self._umount(path) == 0:
+                os.rmdir(path)
+            else:
+                self.logger.warning(
+                    _('Cannot unmount {path}').format(
+                        path=path,
+                    )
+                )
 
     def _getExistingDomain(self):
         self._storageServerConnection()


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I71e78ccab0c25efcd9521938ae3494799786f3d7
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: master
Gerrit-Owner: Sandro Bonazzola <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to