Add DBM Postgres setup module and extract configure_connection - #24052
Draft
sangeetashivaji wants to merge 3 commits into
Draft
Add DBM Postgres setup module and extract configure_connection#24052sangeetashivaji wants to merge 3 commits into
sangeetashivaji wants to merge 3 commits into
Conversation
…le-level function Moves the connection configuration logic out of LRUConnectionPoolManager._configure_connection into a public module-level configure_connection() so it can be shared with the integration-setup CLI (datadog-agent integration setup postgres) without requiring a pool instance or duplicating the logic. LRUConnectionPoolManager._configure_connection now delegates to it, preserving identical behavior for all existing callers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: c984e05 | Docs | Datadog PR Page | Give us feedback! |
Host the Detect/Plan/Apply setup logic in datadog_checks.postgres.setup so the datadog-agent integration-setup CLI can tunnel into it (python -m ...) instead of shipping a standalone copy. Reuses configure_connection, AUTODISCOVERY_QUERY, and parse_shared_preload_libraries, and keeps the canonical datadog helper-function SQL alongside the test compose resources. Skips AWS parameter-group manual steps on re-runs once the value already matches, fixing the non-idempotent exit code. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7 tasks
sangeetashivaji
marked this pull request as draft
June 30, 2026 15:58
Integration tests that run the setup module end-to-end against the live containerized Postgres across the hatch version matrix (9.6 -> 18): dry-run detect/plan, version-specific grant branch, the stdin/stdout CLI contract, and a real apply that verifies idempotency on re-runs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Validation ReportAll 21 validations passed. Show details
|
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?
Hosts the DBM Postgres setup logic in the integration so the
datadog-agent integration setup postgresCLI can tunnel into it(
python -m datadog_checks.postgres.setup) rather than shipping a standalonecopy in the agent.
datadog_checks/postgres/setup.py— the Detect → Plan → Apply logic thatidempotently configures a Postgres instance for DBM (user, grants, server
settings, per-database extension/schema/helper functions). Reads a JSON config
from stdin and writes a JSON result to stdout.
configure_connectionout ofLRUConnectionPoolManager._configure_connectioninto a module-level function so setup configures connections exactly like the
running check (autocommit, SQL_ASCII decoding, CommenterCursor) without a pool
instance. The pool manager now delegates to it; behavior is unchanged.
configure_connection,AUTODISCOVERY_QUERY(database navigation for--all-databases), andparse_shared_preload_libraries.datadog.*helper-function SQL as constants alongsidetests/compose/resources/03_setup.sh, giving a single source of truth in thisrepo (resolves the SQL-drift risk).
already matches, so an already-configured instance verifies cleanly instead of
reporting manual steps forever.
Motivation
Review feedback on DataDog/datadog-agent#51751: the setup logic belongs in the
Python integration where the connection-management and database-navigation code
already lives, with the Go agent acting only as the tunnel to it.
Review checklist (to be filled by reviewers)
qa/requiredif this PR needs QA validation, orqa/skip-qaif it does not. Exactly one of the two is required.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged