Skip to content

Commit

Permalink
pants-plugins/uses_services: use mongo ping instead of deprecated ism…
Browse files Browse the repository at this point in the history
…aster

This matches the method used in st2common.models.db
  • Loading branch information
cognifloyd committed Sep 19, 2024
1 parent 6874d5e commit c4d2605
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pants-plugins/uses_services/scripts/is_mongo_running.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def _is_mongo_running(

# connection.connect() is lazy. Make a command to test the connection.
try:
# The ismaster command is cheap and does not require auth
connection.admin.command("ismaster")
# The ping command is cheap and does not require auth
# https://www.mongodb.com/community/forums/t/how-to-use-the-new-hello-interface-for-availability/116748/
connection.admin.command("ping")
except (ConnectionFailure, ServerSelectionTimeoutError):
return False
return True
Expand Down

0 comments on commit c4d2605

Please sign in to comment.