]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-create-keys: wait 10 minutes to get or create a key, not forever
authorAlfredo Deza <adeza@redhat.com>
Wed, 2 Nov 2016 16:25:32 +0000 (12:25 -0400)
committerNathan Cutler <ncutler@suse.com>
Thu, 5 Jan 2017 21:30:00 +0000 (22:30 +0100)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 8f84681a4d97a7ea6bc04e759eccfc40204a2fdb)

Conflicts:
src/ceph-create-keys ( hammer does not have
            52e978e4b3660baa9f50b1bb8247909b672142e7 )

src/ceph-create-keys

index 6f32070e113b7108b9e972d4a8ac75ab99020659..c2f69423ccb10c5b4bdee0846e51d0930cf98ba6 100755 (executable)
@@ -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_,