[mongo] Fall back to configured host when serverStatus hostname resolution fails#23661
Open
pierreln-dd wants to merge 3 commits into
Open
[mongo] Fall back to configured host when serverStatus hostname resolution fails#23661pierreln-dd wants to merge 3 commits into
pierreln-dd wants to merge 3 commits into
Conversation
…p fails Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Contributor
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 083d1db | Docs | Datadog PR Page | Give us feedback! |
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Contributor
Validation ReportAll 20 validations passed. Show details
|
Codecov Report❌ Patch coverage is Additional details and impacted files🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
When
serverStatus()fails (e.g. transient connection error, Atlas Private Link connectivity issue on first check dispatch), thehostnameproperty inMongoInterfacesilently returnsNone. ThisNonepropagates into_refresh_metadatawhereset_metadata('resolved_hostname', None)is called without a guard, causing the C extension binding to raiseTypeError: argument 3 must be str, not None.This PR fixes both layers:
api.py: Fall back toself._config.hosts[0]whenserverStatus()fails, mirroring how the Postgres integration falls back to the configured DB host when server-side hostname resolution fails. The fallback is not cached in__hostnamesoserverStatus()is retried on subsequent check runs.mongo.py: Add aNoneguard beforeset_metadata('resolved_hostname', ...)as defence-in-depth for any future code path where hostname resolution yieldsNone.Motivation
SDBM-2618: Customer's MongoDB integration running as a cluster check (
cluster_check: true) against an Atlas Private Link endpoint fails withTypeError: argument 3 must be str, not Noneon every check run in production. The cluster check runner node cannot reachserverStatus()on initial dispatch,hostnamereturnsNone, and the uncheckedset_metadatacall crashes. Addingreported_database_hostnameto the config is the confirmed workaround — this PR makes the integration resilient without requiring that config override.Root cause is present since Agent 7.56.0 (mongo check 6.7.0) when
database_autodiscoverywas introduced.Review checklist (to be filled by reviewers)
qa/skip-qalabel if the PR doesn't need to be tested during QA.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged