]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Speed up metadata server registration
authorZane Bitter <zbitter@redhat.com>
Wed, 11 Jul 2012 19:12:23 +0000 (15:12 -0400)
committerZane Bitter <zbitter@redhat.com>
Wed, 11 Jul 2012 19:18:18 +0000 (15:18 -0400)
If heat-engine and heat-metadata were started at approximately the same
time, such that heat-engine was not ready to receive the registration call
from heat-metadata on the first attempt, it would take a minute before the
next retry. Instead, start with a very short timeout (2s) and increase it
if the engine does not show up.

Fixes #159

Change-Id: Ie2efcce667f1dde9ae227a4bb19a1d6a2b7cf135
Signed-off-by: Zane Bitter <zbitter@redhat.com>
bin/heat-metadata

index beb5b1e80f75b5fbe134d15da8851092db251670..fb7802beba3d3c094b495be06fc0d28be187b6d7 100755 (executable)
@@ -45,15 +45,20 @@ LOG = logging.getLogger('heat.metadata')
 
 def send_address_to_engine(host, port):
     con = context.get_admin_context()
+    timeout = 2
     while True:
         try:
             resp = rpc.call(con, 'engine',
                             {'method': 'metadata_register_address',
-                             'args': {'url': 'http://%s:%s' % (host, port)}})
-            LOG.info('registered the hostname and port with the engine.')
-            return
+                             'args': {'url': 'http://%s:%s' % (host, port)}},
+                            timeout=timeout)
         except rpc.common.Timeout:
             LOG.info('Could not connect to the engine, retrying...')
+            if timeout < 30:
+                timeout *= 2
+        else:
+            LOG.info('registered the hostname and port with the engine.')
+            return
 
 
 if __name__ == '__main__':