From a7d919100e9e78b7f821da76b338bca24f374a0a Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Wed, 2 Nov 2016 12:25:32 -0400 Subject: [PATCH] ceph-create-keys: wait 10 minutes to get or create a key, not forever Signed-off-by: Alfredo Deza (cherry picked from commit 8f84681a4d97a7ea6bc04e759eccfc40204a2fdb) Conflicts: src/ceph-create-keys ( hammer does not have 52e978e4b3660baa9f50b1bb8247909b672142e7 ) --- src/ceph-create-keys | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ceph-create-keys b/src/ceph-create-keys index 6f32070e113b7..c2f69423ccb10 100755 --- a/src/ceph-create-keys +++ b/src/ceph-create-keys @@ -58,7 +58,7 @@ def wait_for_quorum(cluster, mon_id): break if wait_count == 0: - LOG.error("ceph-mon was not able to join quorum within ten minutes") + LOG.error("ceph-mon was not able to join quorum within 10 minutes") def get_key(cluster, mon_id): @@ -75,7 +75,8 @@ def get_key(cluster, mon_id): pathdir = os.path.dirname(path) if not os.path.exists(pathdir): os.makedirs(pathdir) - while True: + wait_count = 600 # 10 minutes + while wait_count > 0: try: with file(tmp, 'w') as f: os.fchmod(f.fileno(), 0600) @@ -105,6 +106,7 @@ def get_key(cluster, mon_id): else: LOG.info('Cannot get or create admin key') time.sleep(1) + wait_count -= 1 continue os.rename(tmp, path) @@ -118,6 +120,10 @@ def get_key(cluster, mon_id): else: raise + if wait_count == 0: + raise SystemExit("Could not get or create the admin key after 10 minutes") + + def bootstrap_key(cluster, type_): path = '/var/lib/ceph/bootstrap-{type}/{cluster}.keyring'.format( type=type_, -- 2.39.5