Skip to content

K8SPG-1147: Allow disabling QAN with querySource "none" - #1792

Open
theTibi wants to merge 1 commit into
percona:mainfrom
theTibi:K8SPG-1147
Open

K8SPG-1147: Allow disabling QAN with querySource "none"#1792
theTibi wants to merge 1 commit into
percona:mainfrom
theTibi:K8SPG-1147

Conversation

@theTibi

@theTibi theTibi commented Aug 28, 2026

Copy link
Copy Markdown

CHANGE DESCRIPTION

Problem:

There is no supported way to turn Query Analytics off for a cluster:

spec.pmm.querySource: Unsupported value: "none":
  supported values: "pgstatmonitor", "pgstatstatements"

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.

Cause:

Only the CRD enum rejects none. pmm-admin has accepted it 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. percona/pmm/pmm.go:286 already documents that PMM accepts none.

Solution:

Add none to the querySource enum and regenerate the CRDs.

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.

Verified: make generate VERSION=main produces no drift, full go test ./... passes.

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly? — K8SPG-1147
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)? — not set yet; querySource is documented, so this needs a doc update for the new value
  • Does the Jira ticket link to the proper milestone (Fix Version field)? — not set yet

Tests

  • Is an E2E test/test case added for the new feature/change? — e2e-tests/tests/monitoring/10-disable-qan-query-source.yaml asserts no QAN agent and postgres_exporter still present
  • Are unit tests added where appropriate? — TestQuerySource, TestAgentPrerunScriptQuerySourceNone, and a ToCrunchy case asserting neither extension is installed

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files? — deploy/cr.yaml
  • Are all needed new/changed options added to the Helm Chart? — no change needed; pg-db already passes querySource through, so pmm.querySource: none works once the enum accepts it
  • Did we add proper logging messages for operator actions? — n/a
  • Did we ensure compatibility with the previous version or cluster upgrade process? — additive enum value, existing values unchanged
  • Does the change support oldest and newest supported PG version? — not PG-version dependent
  • Does the change support oldest and newest supported Kubernetes version? — not K8s-version dependent

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>
@it-percona-cla

it-percona-cla commented Aug 28, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@theTibi

theTibi commented Aug 28, 2026

Copy link
Copy Markdown
Author

Be aware I used Claude for this PR. :)

@JNKPercona

Copy link
Copy Markdown
Collaborator
Test Name Result Time
backup-enable-disable passed 00:15:19
builtin-extensions failure 00:00:51
custom-extensions failure 00:00:52
cert-manager-tls passed 00:14:04
cert-management-policy failure 00:02:55
custom-envs passed 00:24:58
custom-tls passed 00:12:30
database-init-sql passed 00:03:13
demand-backup passed 00:25:55
demand-backup-offline-snapshot passed 00:17:46
dynamic-configuration passed 00:03:38
extra-volumes passed 00:03:58
finalizers passed 00:04:00
init-deploy passed 00:03:22
huge-pages passed 00:03:09
logical-replica passed 00:10:09
major-upgrade-14-to-15 passed 00:11:33
major-upgrade-15-to-16 passed 00:12:01
major-upgrade-16-to-17 passed 00:10:22
major-upgrade-17-to-18 passed 00:18:33
major-upgrade-18-to-19 passed 00:10:43
ldap passed 00:03:46
ldap-tls passed 00:05:39
logcollection passed 00:07:44
monitoring passed 00:11:13
operator-upgrade-cert-manager failure 00:03:25
operator-upgrade-extensions passed 00:11:29
one-pod passed 00:06:38
repo-host-autogrow passed 00:02:13
operator-self-healing passed 00:10:50
pgbouncer passed 00:08:26
pg-tde passed 00:12:11
pg-tde-wal-encrypt failure 00:17:59
pitr passed 00:12:21
scaling passed 00:05:27
scheduled-backup passed 00:28:09
self-healing passed 00:09:55
sidecars passed 00:02:54
standby-pgbackrest passed 00:21:03
standby-streaming passed 00:16:40
start-from-backup passed 00:13:19
start-from-volumes passed 00:04:04
tablespaces passed 00:07:41
telemetry-transfer passed 00:04:49
upgrade-consistency passed 00:06:52
upgrade-minor passed 00:17:58
users passed 00:05:53
migration-from-crunchy-standby passed 00:22:26
migration-from-crunchy-pv passed 00:08:26
migration-from-crunchy-backup-restore failure 00:31:26
Summary Value
Tests Run 50/50
Job Duration 02:56:15
Total Test Time 08:51:10

commit: dafcb3d
image: perconalab/percona-postgresql-operator:PR-1792-dafcb3da0

Comment thread deploy/cr.yaml
# cpu: 300m
# customClusterName: "<string>"
# postgresParams: "<string>"
# # Query Analytics source: pgstatstatements (default), pgstatmonitor, or none to disable QAN.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this comment is not needed

@egegunes

Copy link
Copy Markdown
Contributor

@hors would it be okay to add this into v3.1.0?

@hors

hors commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

@hors would it be okay to add this into v3.1.0?

I am not sure that we can include it in v3.1.0 :( We need to start release and can't wait. @theTibi, can you use the operator without this fix for PMM deployment?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 allowed PMMQuerySource value and documented its behavior in the API types.
  • Updated PMM mapping/tests to ensure "none" is passed through correctly and doesn’t enable either pg_stat_statements or pg_stat_monitor extensions.
  • Added an E2E (KUTTL) test verifying no QAN agent is registered while postgres_exporter remains 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants