]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Allow engine and metadata server start in any order
authorTomas Sedovic <tomas@sedovic.cz>
Thu, 17 May 2012 14:49:15 +0000 (16:49 +0200)
committerTomas Sedovic <tomas@sedovic.cz>
Thu, 17 May 2012 14:49:15 +0000 (16:49 +0200)
When the metadata server starts first, it will wait for the engine to come up
and only then registers it's hostname and port and becomes available.

Signed-off-by: Tomas Sedovic <tomas@sedovic.cz>
bin/heat-metadata

index 985e0e32213c2edf0481111813c26d6762ef2fe6..c18ecadd92e45afd83f4df95f8bae7c5c1a06007 100755 (executable)
@@ -45,9 +45,15 @@ LOG = logging.getLogger('heat.metadata')
 
 def send_address_to_engine(host, port):
     con = context.get_admin_context()
-    resp = rpc.call(con, 'engine',
-                    {'method': 'metadata_register_address',
-                     'args': {'url': 'http://%s:%s' % (host, port)}})
+    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
+        except rpc.common.Timeout:
+            LOG.info('Could not connect to the engine, retrying...')
 
 
 if __name__ == '__main__':