summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster
diff options
context:
space:
mode:
authorSri Vignesh <sselvan@redhat.com>2020-02-13 15:13:13 +0530
committerVaibhav Mahajan <vamahaja@redhat.com>2020-02-17 07:03:59 +0000
commit49e9cdbc710ed25434f5e7faec94281afa8d54ce (patch)
tree1e50919861530bc2c592fc2f1d17e1160bd3f621 /glustolibs-gluster
parent58a71f32c632c433c2db2672bb21fb2781dfac87 (diff)
[Libfix] Add steps to bring bricks online and volume reset
Add steps to include bring offline bricks to online and volume reset in case of failure scenarios Change-Id: I9bdadd8a80ded81cf7cb4e324a18321400bfcc4c Signed-off-by: Sri Vignesh <sselvan@redhat.com>
Diffstat (limited to 'glustolibs-gluster')
-rw-r--r--glustolibs-gluster/glustolibs/gluster/gluster_base_class.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
index 7cd128f1a..3046dc442 100644
--- a/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
+++ b/glustolibs-gluster/glustolibs/gluster/gluster_base_class.py
@@ -50,7 +50,10 @@ from glustolibs.gluster.volume_libs import (
setup_volume,
wait_for_volume_process_to_be_online,
)
-from glustolibs.gluster.volume_ops import set_volume_options
+from glustolibs.gluster.brick_libs import (
+ wait_for_bricks_to_be_online, get_offline_bricks_list)
+from glustolibs.gluster.volume_ops import (
+ set_volume_options, volume_reset, volume_start)
from glustolibs.io.utils import log_mounts_info
@@ -385,6 +388,29 @@ class GlusterBaseClass(TestCase):
return True
@classmethod
+ def bricks_online_and_volume_reset(cls):
+ """
+ reset the volume if any bricks are offline.
+ waits for all bricks to be online and resets
+ volume options set
+ """
+ bricks_offline = get_offline_bricks_list(cls.mnode, cls.volname)
+ if bricks_offline is not None:
+ ret = volume_start(cls.mnode, cls.volname, force=True)
+ if not ret:
+ raise ExecutionError("Failed to force start volume"
+ "%s" % cls.volname)
+ ret = wait_for_bricks_to_be_online(cls.mnode, cls.volname)
+ if not ret:
+ raise ExecutionError("Failed to bring bricks online"
+ "for volume %s" % cls.volname)
+
+ ret, _, _ = volume_reset(cls.mnode, cls.volname, force=True)
+ if ret:
+ raise ExecutionError("Failed to reset volume %s" % cls.volname)
+ g.log.info("Successful in volume reset %s", cls.volname)
+
+ @classmethod
def unmount_volume(cls, mounts):
"""Unmount all mounts for the volume
@@ -460,6 +486,7 @@ class GlusterBaseClass(TestCase):
Returns (bool): True if cleanup volume is successful. False otherwise.
"""
+ cls.bricks_online_and_volume_reset()
g.log.info("Cleanup Volume %s", cls.volname)
ret = cleanup_volume(mnode=cls.mnode, volname=cls.volname)
if not ret: