]> 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>
Mon, 14 Nov 2016 16:08:00 +0000 (17:08 +0100)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 8f84681a4d97a7ea6bc04e759eccfc40204a2fdb)

src/ceph-create-keys

index 78525c634be5d6eb329c536513771723023aa98f..ea19857ae5bc79620b16e69929bc85e13347936f 100755 (executable)
@@ -74,7 +74,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):
@@ -93,7 +93,8 @@ def get_key(cluster, mon_id):
         os.makedirs(pathdir)
         os.chmod(pathdir, 0770)
         os.chown(pathdir, get_ceph_uid(), get_ceph_gid())
-    while True:
+    wait_count = 600  # 10 minutes
+    while wait_count > 0:
         try:
             with file(tmp, 'w') as f:
                 os.fchmod(f.fileno(), 0600)
@@ -141,6 +142,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)
@@ -154,6 +156,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_,