Browse Source

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
Stan Lagun 3 years ago
parent
commit
d8ece93ac5
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      muranoagent/app.py

+ 6
- 1
muranoagent/app.py View File

@@ -124,6 +124,7 @@ class MuranoAgent(service.Service):
124 124
 
125 125
     def _wait_plan(self):
126 126
         delay = 5
127
+        reconnect = False
127 128
         while True:
128 129
             try:
129 130
                 with self._create_rmq_client() as mq:
@@ -134,10 +135,14 @@ class MuranoAgent(service.Service):
134 135
                             if msg is not None and isinstance(msg.body, dict):
135 136
                                 self._handle_message(msg)
136 137
 
138
+                            delay = 5
137 139
                             if msg is not None:
138 140
                                 msg.ack()
139 141
                                 yield
140
-                            delay = 5
142
+                                reconnect = True
143
+                            elif reconnect:
144
+                                reconnect = False
145
+                                break
141 146
             except KeyboardInterrupt:
142 147
                 break
143 148
             except Exception:

Loading…
Cancel
Save