summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster
diff options
context:
space:
mode:
authorPrasad Desala <tdesala@redhat.com>2018-01-30 12:16:57 +0530
committerNigel Babu <nigelb@redhat.com>2018-05-16 09:11:27 +0000
commit163e6d0dbfd9de07d70babf751989050931ad0e2 (patch)
treea7c0775cb781deee96d70bd1928f91c9ebcb9522 /glustolibs-gluster/glustolibs/gluster
parent615d7886ee4d8cd6b9b9ab21e4e2b486fb4bb2fd (diff)
Check for failure in rebalance aggregate status in lib functions
* wait_for_fix_layout_to_complete * wait_for_rebalance_to_complete Change-Id: I6e243725040f9d7bd7b46e00292771e76ee6fadf Signed-off-by: Prasad Desala <tdesala@redhat.com>
Diffstat (limited to 'glustolibs-gluster/glustolibs/gluster')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/rebalance_ops.py40
1 files changed, 19 insertions, 21 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py b/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py
index 3c5615f..1c8c10a 100644
--- a/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py
+++ b/glustolibs-gluster/glustolibs/gluster/rebalance_ops.py
@@ -19,8 +19,8 @@
Description: Library for gluster rebalance operations.
"""
-from glusto.core import Glusto as g
import time
+from glusto.core import Glusto as g
try:
import xml.etree.cElementTree as etree
@@ -282,25 +282,24 @@ def wait_for_fix_layout_to_complete(mnode, volname, timeout=300):
"""
count = 0
- flag = 0
- while (count < timeout):
+ while count < timeout:
status_info = get_rebalance_status(mnode, volname)
if status_info is None:
return False
status = status_info['aggregate']['statusStr']
if status == 'fix-layout completed':
- flag = 1
- break
+ g.log.info("Fix-layout is successfully completed")
+ return True
+ if status == 'fix-layout failed':
+ g.log.error("Fix-layout failed on one or more nodes."
+ "Check rebalance status for more details")
+ return False
time.sleep(10)
count = count + 10
- if not flag:
- g.log.error("Fix-layout is not completed")
- return False
- else:
- g.log.info("Fix-layout is successfully completed")
- return True
+ g.log.error("Fix layout has not completed. Wait timeout.")
+ return False
def wait_for_rebalance_to_complete(mnode, volname, timeout=300):
@@ -322,25 +321,24 @@ def wait_for_rebalance_to_complete(mnode, volname, timeout=300):
"""
count = 0
- flag = 0
- while (count < timeout):
+ while count < timeout:
status_info = get_rebalance_status(mnode, volname)
if status_info is None:
return False
status = status_info['aggregate']['statusStr']
if status == 'completed':
- flag = 1
- break
+ g.log.info("Rebalance is successfully completed")
+ return True
+ if status == 'failed':
+ g.log.error(" Rebalance failed on one or more nodes."
+ "Check rebalance status for more details")
+ return False
time.sleep(10)
count = count + 10
- if not flag:
- g.log.error("rebalance is not completed")
- return False
- else:
- g.log.info("rebalance is successfully completed")
- return True
+ g.log.error("Rebalance operation has not completed. Wait timeout.")
+ return False
def get_remove_brick_status(mnode, volname, bricks_list):