From a16642d19d52d2a6818146cf89febffc0fc84526 Mon Sep 17 00:00:00 2001 From: lukepatrick Date: Tue, 13 Jul 2021 12:54:43 -0600 Subject: [PATCH] update db connect mongo connection test --- CHANGELOG.rst | 4 ++++ st2common/st2common/models/db/__init__.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a60570a82e..5762d4962e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,10 @@ Changed Contributed by @ericreeves. +* update db connect mongo connection test - `isMaster` MongoDB command depreciated, switch to `hello` #5302 + + Contributed by @lukepatrick + 3.5.0 - June 23, 2021 --------------------- diff --git a/st2common/st2common/models/db/__init__.py b/st2common/st2common/models/db/__init__.py index 9ed99c7c91..fe21aa0a6b 100644 --- a/st2common/st2common/models/db/__init__.py +++ b/st2common/st2common/models/db/__init__.py @@ -199,8 +199,9 @@ def _db_connect( # successfully established. # See http://api.mongodb.com/python/current/api/pymongo/mongo_client.html for details try: - # The ismaster command is cheap and does not require auth - connection.admin.command("ismaster") + # The hello command is cheap and does not require auth + # https://docs.mongodb.com/v4.4/reference/command/hello/ + connection.admin.command("hello") except (ConnectionFailure, ServerSelectionTimeoutError) as e: # NOTE: ServerSelectionTimeoutError can also be thrown if SSLHandShake fails in the server # Sadly the client doesn't include more information about the error so in such scenarios