Adds RMQ reconnection on first timeout after EP run

Execution plan can modify iptables rules causing
RabbitMQ connection to break without agent
being notified. Thus it will just not get all subsequent
execution plans.

This commit reestablishes connection upon first
5-second timeout after last executed EP so it
it broke the connection it will be fixed in
5 seconds.

Change-Id: I90c8e062be8528ffd81a295a209c3ec029fc2cd8
Closes-Bug: #1556895
This commit is contained in:
Stan Lagun 2016-03-17 01:23:04 +03:00
parent 75faffbb81
commit d8ece93ac5
1 changed files with 6 additions and 1 deletions

View File

@ -124,6 +124,7 @@ class MuranoAgent(service.Service):
def _wait_plan(self):
delay = 5
reconnect = False
while True:
try:
with self._create_rmq_client() as mq:
@ -134,10 +135,14 @@ class MuranoAgent(service.Service):
if msg is not None and isinstance(msg.body, dict):
self._handle_message(msg)
delay = 5
if msg is not None:
msg.ack()
yield
delay = 5
reconnect = True
elif reconnect:
reconnect = False
break
except KeyboardInterrupt:
break
except Exception: