From 53c6b3cd7ede1ffe1927b08b727e9e881d433a33 Mon Sep 17 00:00:00 2001 From: Atul Agarwal Date: Mon, 15 Mar 2021 16:57:26 +0000 Subject: [PATCH] Fix for bug 1433 - Exception when checking kafka status Change-Id: I7811acab85ad88f1c691034bb07cdc464ad5b2b1 Signed-off-by: Atul Agarwal (cherry picked from commit 3e56247016997c027c9350b9515821a2bd92bc5c) --- osm_mon/cmd/common_functions.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osm_mon/cmd/common_functions.py b/osm_mon/cmd/common_functions.py index 5e4bff8..b85a90e 100644 --- a/osm_mon/cmd/common_functions.py +++ b/osm_mon/cmd/common_functions.py @@ -42,10 +42,13 @@ def wait_till_core_services_are_ready(config, process_name="osm-mon", commondb_w # Check if kafka is ready while(True): port_in_use = False - # Logic to check kafka is ready - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - if s.connect_ex(("kafka", int(config.conf["message"].get("port")))) == 0: - port_in_use = True + try: + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + if s.connect_ex(("kafka", int(config.conf["message"].get("port")))) == 0: + port_in_use = True + except Exception as e: + logging.info("Error when trying to get kafka status.") + logging.debug("Exception when trying to get kafka status: %s", str(e)) if port_in_use: break else: -- 2.25.1