Don't begin heartbeating until the API server is listening

As soon as the agent sends its first heartbeat, it may begin receiving
API calls. As such, we should wait until the server is actually
listening before starting the heartbeater.

Change-Id: Id2984f3f0f50cdb725b10913d38b990f99c48b0a
This commit is contained in:
Russell Haering
2014-05-20 14:45:39 -07:00
parent 59d6523a35
commit cad3588071

@@ -171,13 +171,16 @@ class IronicPythonAgent(base.ExecuteCommandMixin):
self.node = content['node']
self.heartbeat_timeout = content['heartbeat_timeout']
self.heartbeater.start()
wsgi = simple_server.make_server(
self.listen_address[0],
self.listen_address[1],
self.api,
server_class=simple_server.WSGIServer)
# Don't start heartbeating until the server is listening
self.heartbeater.start()
try:
wsgi.serve_forever()
except BaseException: