VOL-2098 Monitor Kafka service readiness
Change-Id: Ifb9658c8ea4f03374fe2921846149b1e55237327
diff --git a/python/ofagent/connection_mgr.py b/python/ofagent/connection_mgr.py
index a141946..3b10280 100755
--- a/python/ofagent/connection_mgr.py
+++ b/python/ofagent/connection_mgr.py
@@ -38,6 +38,7 @@
class ConnectionManager(object):
running = False
+ core_ready = False
channel = None
subscription = None
grpc_client = None
@@ -83,6 +84,7 @@
log.debug('starting')
self.running = True
+ ConnectionManager.core_ready = True # Assume core is ready until proven otherwise
ConnectionManager.running = True
# Get a subscription to vcore
@@ -103,7 +105,7 @@
@classmethod
def readiness_probe(cls):
# Pod is isolated when readiness condition fails
- return bool(ConnectionManager.channel and ConnectionManager.subscription and ConnectionManager.grpc_client)
+ return bool(ConnectionManager.core_ready and ConnectionManager.channel and ConnectionManager.subscription and ConnectionManager.grpc_client)
def stop(self):
log.debug('stopping')
@@ -228,13 +230,14 @@
@inlineCallbacks
def get_list_of_logical_devices_from_voltha(self):
-
while self.running:
log.info('retrieve-logical-device-list')
try:
devices = yield \
self.grpc_client.list_logical_devices()
+ ConnectionManager.core_ready = True # We've successfully talked to the core
+
for device in devices:
log.info("logical-device-entry", id=device.id,
datapath_id=device.datapath_id)
@@ -244,11 +247,11 @@
except _Rendezvous, e:
status = e.code()
log.error('vcore-communication-failure', exception=e, status=status)
- if status == StatusCode.UNAVAILABLE or status == StatusCode.DEADLINE_EXCEEDED:
- os.system("kill -15 {}".format(os.getpid()))
+ ConnectionManager.core_ready = False # Will be reflected in readiness probe
except Exception as e:
log.exception('logical-devices-retrieval-failure', exception=e)
+ ConnectionManager.core_ready = False # will be reflected in readiness probe
log.info('reconnect', after_delay=self.vcore_retry_interval)
yield asleep(self.vcore_retry_interval)