Add manager_available() and wait_for_manager() methods
These methods combine to provide a mechanism to wait for the mgr daemon to be available before performing commands that rely on the daemon being available; e.g. the adding a mgr module like pg-autotune. Change-Id: I6255a2e947053a6f8d545aa3f6be1a8330d8bd57
This commit is contained in:
parent
ee5de74d0a
commit
727a9dd156
@ -793,12 +793,33 @@ def is_leader():
|
||||
return False
|
||||
|
||||
|
||||
def manager_available():
|
||||
# if manager daemon isn't on this release, just say it is Fine
|
||||
if cmp_pkgrevno('ceph', '11.0.0') < 0:
|
||||
return True
|
||||
cmd = ["sudo", "-u", "ceph", "ceph", "mgr", "dump", "-f", "json"]
|
||||
try:
|
||||
result = json.loads(subprocess.check_output(cmd).decode('UTF-8'))
|
||||
return result['available']
|
||||
except subprocess.CalledProcessError as e:
|
||||
log("'{}' failed: {}".format(" ".join(cmd), str(e)))
|
||||
return False
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def wait_for_quorum():
|
||||
while not is_quorum():
|
||||
log("Waiting for quorum to be reached")
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
def wait_for_manager():
|
||||
while not manager_available():
|
||||
log("Waiting for manager to be available")
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
def add_bootstrap_hint(peer):
|
||||
asok = "/var/run/ceph/ceph-mon.{}.asok".format(socket.gethostname())
|
||||
cmd = [
|
||||
|
Loading…
Reference in New Issue
Block a user