PMM-15238: Expose the built-in PostgreSQL to SEP - #5700
Open
ademidoff wants to merge 2 commits into
Open
Conversation
Add an opt-in integration that lets SEP, running in a side container on a shared Docker bridge network, use PMM's embedded PostgreSQL for its persistence layer. When PMM_ENABLE_SEP is set, the entrypoint appends marker-delimited blocks to postgresql.conf (listen_addresses) and pg_hba.conf (one scram-sha-256 rule per attached Docker subnet, scoped to the sep database and role), then provisions a non-superuser sep role owning a dedicated sep database. Nothing is published on the host, and the postgres, pmm-managed and grafana accounts remain unreachable over the network. Unsetting the variable reverts the configuration on the next start and leaves the role and database intact. The postgres data directory, password file and binary directory are now declared once in the entrypoint and passed to the helper scripts via a subshell-scoped export, replacing the /usr/pgsql-14 literals that were duplicated across them.
ademidoff
requested review from
4nte and
JiriCtvrtka
and removed request for
a team
July 26, 2026 23:24
1 task
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5700 +/- ##
==========================================
+ Coverage 43.59% 45.19% +1.59%
==========================================
Files 415 418 +3
Lines 43134 43331 +197
==========================================
+ Hits 18804 19583 +779
+ Misses 22454 21807 -647
- Partials 1876 1941 +65
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
JiriCtvrtka
approved these changes
Jul 27, 2026
4nte
approved these changes
Jul 27, 2026
1 task
1 task
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.
Ticket number: PMM-15238
Feature build: Percona-Lab/pmm-submodules#4495
Lets SEP, running in a side container on a shared Docker bridge network, use PMM's embedded PostgreSQL for its persistence layer. Entirely opt-in — with
PMM_ENABLE_SEPunset, nothing about PMM changes.What it does
When
PMM_ENABLE_SEP=1andPMM_SEP_POSTGRES_PASSWORDare set, the entrypoint runs a new helper (build/ansible/roles/postgres/files/postgres-sep) before supervisord starts. It:postgresql.confsettinglisten_addresses = '*'— this only covers the container's own network namespace, nothing is published on the host;pg_hba.confwith onescram-sha-256rule per attached Docker subnet (derived fromip -o -4 route show scope link), scoped to thesepdatabase andsepuser only;seprole (NOSUPERUSER NOCREATEROLE NOCREATEDB) owning a dedicatedsepdatabase.The
postgres,pmm-managedandgrafanaaccounts stay unreachable over the network — Postgres rejects them withno pg_hba.conf entry.Both config blocks are delimited by
# BEGIN PMM SEP/# END PMM SEPand rewritten on every start, so the operation is idempotent. UnsettingPMM_ENABLE_SEPstrips them on the next start and returns Postgres to loopback-only; theseprole and database are deliberately left in place, since a config flag should not destroy data.Drive-by: PG version literals
/srv/postgres14,/srv/.postgres_passwordand/usr/pgsql-14/binwere duplicated across the entrypoint andpostgres-migration. They are now declared once inbuild/docker/server/entrypoint.shand passed to both helper scripts via a subshell-scoped export, so they do not leak into the environment supervisord and its children inherit (verified across every/proc/*/environ). Each script aborts with a named message if one is missing.psqlnow resolves through$POSTGRES_BIN_DIRrather than/usr/bin/psql, which is an alternatives symlink — fine today, but it resolves to whichever version alternatives prefers, exactly the wrong property during a 14 → 18 migration with both installed.Still pinned to 14 and out of scope here:
build/ansible/roles/supervisord/files/pmm.ini,managed/services/supervisord/pmm_config.go, and thebuild/ansible/roles/postgres/tasks/*.ymlplaybooks.Testing
Verified against
percona/pmm-server:3.8.1with the scripts bind-mounted, using a psql client container on a shared bridge network.sep@sepconnects, DDL/DML works,pg_stat_statementscreatedsep→pmm-managed/postgressuperuser /grafanaover the networkno pg_hba.conf entryrolsuper,rolcreatedb,rolcreateroleall falsePMM_ENABLE_SEPunsetseprole and database survivePMM_SEP_POSTGRES_PASSWORDPMM_DISABLE_BUILTIN_POSTGRES=1/PMM_HA_ENABLE=1hostrule per subnet, connects from bothreadyzOK,health=healthyPOSTGRES_*in supervisord and all childrenshellcheckclean on all three scripts;go test ./managed/utils/envvars/...passes.Notes
pmm-managedandgrafana, or thesepdatabase will be silently dropped — nothing in PMM's code references it, so the omission would not be caught.