K8SPG-1147: Allow disabling QAN with querySource "none" - #1792
Conversation
The querySource enum allowed only pgstatmonitor and pgstatstatements, so there
was no supported way to turn Query Analytics off for a cluster:
spec.pmm.querySource: Unsupported value: "none":
supported values: "pgstatmonitor", "pgstatstatements"
Only the CRD enum rejected it. pmm-admin has accepted "none" since 2021: the
flag carries no enum tag, "none" is an explicit case in its query-source switch
that leaves both QAN agent flags false, and managed creates postgres_exporter
unconditionally while gating each QAN agent separately. The service registers,
metrics keep flowing, and no QAN agent is created.
This matters for PMM HA, where PMM's own PostgreSQL is an internal component
whose queries should not appear in QAN. Since 2.9.0 the default is
pgstatstatements and it resolves correctly, so QAN is on by default there with
no way to disable it.
No version gate: widening an enum is backward compatible, and "none" needs no
remapping in querySource(). Extension defaulting already handles it, since both
pg_stat_statements and pg_stat_monitor compare false against it.
Signed-off-by: theTibi <tkorocz@gmail.com>
|
Be aware I used Claude for this PR. :) |
commit: dafcb3d |
| # cpu: 300m | ||
| # customClusterName: "<string>" | ||
| # postgresParams: "<string>" | ||
| # # Query Analytics source: pgstatstatements (default), pgstatmonitor, or none to disable QAN. |
There was a problem hiding this comment.
i think this comment is not needed
|
@hors would it be okay to add this into v3.1.0? |
There was a problem hiding this comment.
🟢 Approval recommended
The change is a backward-compatible enum widening with both unit and E2E coverage confirming the intended “disable QAN, keep metrics” behavior.
Pull request overview
This PR expands the PerconaPGCluster PMM spec.pmm.querySource API to support "none" so operators can disable Query Analytics (QAN) while keeping metrics collection enabled, aligning the CRD validation with existing pmm-admin behavior.
Changes:
- Added
"none"as an allowedPMMQuerySourcevalue and documented its behavior in the API types. - Updated PMM mapping/tests to ensure
"none"is passed through correctly and doesn’t enable eitherpg_stat_statementsorpg_stat_monitorextensions. - Added an E2E (KUTTL) test verifying no QAN agent is registered while
postgres_exporterremains present; regenerated CRDs/bundles to include the new enum value.
File summaries
| File | Description |
|---|---|
| pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go | Adds QuerySourceNone and updates the CRD enum/docs for spec.pmm.querySource. |
| pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go | Unit test coverage ensuring no query-source extension is enabled when querySource=none. |
| percona/pmm/pmm_test.go | Unit tests for querySource mapping and for emitting --query-source=none in the PMM agent script. |
| e2e-tests/tests/monitoring/10-disable-qan-query-source.yaml | KUTTL step validating QAN is disabled (no QAN agent) while metrics collection continues. |
| deploy/cw-bundle.yaml | Regenerated bundle CRD enum includes none. |
| deploy/crd.yaml | Regenerated CRD enum includes none. |
| deploy/bundle.yaml | Regenerated bundle CRD enum includes none. |
| config/crd/bases/pgv2.percona.com_perconapgclusters.yaml | Base CRD updated to allow none for querySource. |
| build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml | Generated CRD updated to allow none for querySource. |
| deploy/cr.yaml | Sample CR comment updated to document none as an option to disable QAN. |
Review details
- Files reviewed: 9/10 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
CHANGE DESCRIPTION
Problem:
There is no supported way to turn Query Analytics off for a cluster:
This matters for PMM HA, where PMM's own PostgreSQL is an internal component whose queries should not appear in QAN. Since 2.9.0 the default is
pgstatstatementsand it resolves correctly, so QAN is on by default there with no way to disable it.Cause:
Only the CRD enum rejects
none.pmm-adminhas accepted it since 2021: the flag carries no enum tag,noneis an explicit case in its query-source switch that leaves both QAN agent flags false, andmanagedcreatespostgres_exporterunconditionally while gating each QAN agent separately. The service registers, metrics keep flowing, and no QAN agent is created.percona/pmm/pmm.go:286already documents that PMM acceptsnone.Solution:
Add
noneto thequerySourceenum and regenerate the CRDs.No version gate: widening an enum is backward compatible, and
noneneeds no remapping inquerySource(). Extension defaulting already handles it, since bothpg_stat_statementsandpg_stat_monitorcompare false against it.Verified:
make generate VERSION=mainproduces no drift, fullgo test ./...passes.CHECKLIST
Jira
Needs Doc) and QA (Needs QA)? — not set yet;querySourceis documented, so this needs a doc update for the new valueTests
e2e-tests/tests/monitoring/10-disable-qan-query-source.yamlasserts no QAN agent andpostgres_exporterstill presentTestQuerySource,TestAgentPrerunScriptQuerySourceNone, and aToCrunchycase asserting neither extension is installedConfig/Logging/Testability
deploy/cr.yamlpg-dbalready passesquerySourcethrough, sopmm.querySource: noneworks once the enum accepts it