X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcmd%2Fcommon_functions.py;h=78f924221c6fa4581f67a8074e40ae78d2603fe3;hb=cb6abac8bf7111d38ed77f7f136afa33eeaa8734;hp=5e4bff8adad0809c3e742d7e88c17c723529a16b;hpb=5aa710b2f20055daed07dcf474ce64062ec55dfa;p=osm%2FMON.git diff --git a/osm_mon/cmd/common_functions.py b/osm_mon/cmd/common_functions.py index 5e4bff8..78f9242 100644 --- a/osm_mon/cmd/common_functions.py +++ b/osm_mon/cmd/common_functions.py @@ -42,10 +42,21 @@ 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( + ( + config.conf.get("message", {}).get("host", "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: