diff options
author | srijan-sivakumar <ssivakum@redhat.com> | 2020-11-26 11:05:46 +0530 |
---|---|---|
committer | Arthy Loganathan <aloganat@redhat.com> | 2020-11-27 05:06:33 +0000 |
commit | c5934fee66faa516ba495c32f7ec62d10b9301fd (patch) | |
tree | 4526917563c508e50f1d531d8c4aa3060e46a8b7 | |
parent | 286512294dd2b1829743b718dd5db671342ba06e (diff) |
[LibFix] Adding retry for start_glusterd
Issue: Glusterd start fails after repeated start and stop. ( Due to
the cap on maximum of 6 starts of the service within an hour )
Fix: Hence it is prudent to add the retry option similar to that
of restart_glusterd so as to run `systemctl reset-failed glusterd`
on the servers.
Change-Id: Ic0378934623dfa6dc5ab265246c746269f6995bc
Signed-off-by: srijan-sivakumar <ssivakum@redhat.com>
-rw-r--r-- | glustolibs-gluster/glustolibs/gluster/gluster_init.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/gluster_init.py b/glustolibs-gluster/glustolibs/gluster/gluster_init.py index d6740b773..6a49ffc8b 100644 --- a/glustolibs-gluster/glustolibs/gluster/gluster_init.py +++ b/glustolibs-gluster/glustolibs/gluster/gluster_init.py @@ -23,13 +23,17 @@ from time import sleep from glusto.core import Glusto as g -def start_glusterd(servers): +def start_glusterd(servers, enable_retry=True): """Starts glusterd on specified servers if they are not running. Args: servers (str|list): A server|List of server hosts on which glusterd has to be started. + Kwargs: + enable_retry(Bool): If set to True then runs reset-failed else + do nothing. + Returns: bool : True if starting glusterd is successful on all servers. False otherwise. @@ -46,10 +50,13 @@ def start_glusterd(servers): if retcode != 0: g.log.error("Unable to start glusterd on server %s", server) _rc = False - if not _rc: - return False + if not _rc and enable_retry: + ret = reset_failed_glusterd(servers) + if ret: + ret = start_glusterd(servers) + return ret - return True + return _rc def stop_glusterd(servers): |