[Kimchi-devel] [PATCH v2 2/3] Github bug #327: NFS pool workaround: timeout adjustments
Daniel Barboza
danielhb at linux.vnet.ibm.com
Tue Feb 25 18:45:50 UTC 2014
From: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
Adding a smaller timeout in the 'prepare()' method of
libvirtstoragepool ('mount' and 'umount' commands).
Fixing an error in utils/run_command() that prevented the
TimeoutExpired exception to be raised sometimes.
Signed-off-by: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
---
src/kimchi/model/libvirtstoragepool.py | 9 ++++++---
src/kimchi/utils.py | 2 +-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/kimchi/model/libvirtstoragepool.py b/src/kimchi/model/libvirtstoragepool.py
index dc38d50..e69971b 100644
--- a/src/kimchi/model/libvirtstoragepool.py
+++ b/src/kimchi/model/libvirtstoragepool.py
@@ -94,15 +94,18 @@ class NetfsPoolDef(StoragePoolDef):
export_path, mnt_point]
umount_cmd = ["umount", "-f", export_path]
mounted = False
+ # 2 seconds looks like a reasonable time to wait for a refresh
+ # in the UI and enough time to verify that the NFS server
+ # is down.
+ cmd_timeout = 2
with RollbackContext() as rollback:
rollback.prependDefer(os.rmdir, mnt_point)
try:
- run_command(mount_cmd, 30)
- rollback.prependDefer(run_command, umount_cmd)
+ run_command(mount_cmd, cmd_timeout)
+ rollback.prependDefer(run_command, umount_cmd, cmd_timeout)
except TimeoutExpired:
raise InvalidParameter("KCHPOOL0012E", {'path': export_path})
-
with open("/proc/mounts", "rb") as f:
rawMounts = f.read()
output_items = ['dev_path', 'mnt_point', 'type']
diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py
index 6be1c04..d4ab1a1 100644
--- a/src/kimchi/utils.py
+++ b/src/kimchi/utils.py
@@ -177,7 +177,7 @@ def run_command(cmd, timeout=None):
"timeout %s seconds" % timeout)
kimchi_log.error(msg)
- msg_args = {'cmd': cmd, 'seconds': timeout}
+ msg_args = {'cmd': " ".join(cmd), 'seconds': str(timeout)}
raise TimeoutExpired("KCHUTILS0002E", msg_args)
return out, error, proc.returncode
--
1.8.3.1
More information about the Kimchi-devel
mailing list