Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions monitoring/uss_qualifier/resources/interuss/datastore/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,18 @@ def is_reachable(self) -> Tuple[bool, Optional[psycopg.Error]]:
or 2) that the connection succeeds.
"""
try:
c = self.connect(sslmode="allow", require_auth="password", password="dummy")
c = self.connect(
sslmode="prefer", require_auth="password", password="dummy"
)
c.close()
except psycopg.OperationalError as e:
err_msg = str(e)
is_reachable = "password authentication failed" in err_msg
# First message is returned if password authentication is enabled
# (CockroachDB), second one if not (Yugabyte use certificates)
is_reachable = (
"password authentication failed" in err_msg
or "server did not complete authentication" in err_msg
)
return is_reachable, e
return True, None

Expand All @@ -121,7 +128,12 @@ def runs_in_secure_mode(self) -> Tuple[bool, Optional[psycopg.Error]]:
c.close()
except psycopg.OperationalError as e:
err_msg = str(e)
secure_mode = "node is running secure mode" in err_msg
# First message is returned by CockroachDB, second one by Yugabyte
# (No hba entries for authentication outside SSL)
secure_mode = (
"node is running secure mode" in err_msg
or "no pg_hba.conf entry for host" in err_msg
)
return secure_mode, e
return False, None

Expand Down
Loading