Skip to content

Commit c370c7b

Browse files
authored
Resovle db_host to itself for .local hosts (#19039)
* Resovle db_host to itself for .local hosts * Add test case * Changelog * Changelog * None check
1 parent d4b7a05 commit c370c7b

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
When resolving database hosts, always resolve a .local database host to itself

datadog_checks_base/datadog_checks/base/utils/db/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ def acquire(self, key):
150150

151151

152152
def resolve_db_host(db_host):
153+
if db_host and db_host.endswith('.local'):
154+
return db_host
155+
153156
agent_hostname = datadog_agent.get_hostname()
154157
if not db_host or db_host in {'localhost', '127.0.0.1'} or db_host.startswith('/'):
155158
return agent_hostname

datadog_checks_base/tests/base/utils/db/test_util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
("192.0.2.1", "greater-than-or-equal-to-64-characters-causes-unicode-error-----", "192.0.2.1"),
4040
("192.0.2.1", "192.0.2.1", "192.0.2.1"),
4141
("192.0.2.1", "192.0.2.254", "192.0.2.1"),
42+
("postgres.svc.local", "some-pod", "postgres.svc.local"),
4243
],
4344
)
4445
def test_resolve_db_host(db_host, agent_hostname, want):

0 commit comments

Comments
 (0)