From 5dfba1d5355150a8d5a45490fab2f4e7b561d932 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 29 Apr 2021 17:42:54 +0200 Subject: [PATCH] fix mongo validation with lower timeout --- igniter/tools.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/igniter/tools.py b/igniter/tools.py index 55ea4b98e9..5ebd34d891 100644 --- a/igniter/tools.py +++ b/igniter/tools.py @@ -119,22 +119,12 @@ def validate_mongo_connection(cnx: str) -> (bool, str): parsed = urlparse(cnx) if parsed.scheme not in ["mongodb", "mongodb+srv"]: return False, "Not mongodb schema" - # we have mongo connection string. Let's try if we can connect. - try: - components = decompose_url(cnx) - except RuntimeError: - return False, f"Invalid port specified." - - mongo_args = { - "host": compose_url(**components), - "serverSelectionTimeoutMS": 2000 - } - port = components.get("port") - if port is not None: - mongo_args["port"] = int(port) try: - client = MongoClient(cnx) + client = MongoClient( + cnx, + serverSelectionTimeoutMS=2000 + ) client.server_info() client.close() except ServerSelectionTimeoutError as e: