Skip to content

feat: collect logs with the operator's log collector, on for new instances - #91

Merged
oksana-grishchenko merged 8 commits into
mainfrom
feat/logcollector
Nov 19, 2026
Merged

oksana-grishchenko merged 8 commits into
mainfrom
feat/logcollector

Conversation

@spron-in

@spron-in spron-in commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Stacked on #90 (operator 3.1.0 bump). Review that first; this PR's base will switch to main once it merges.

Why

Today PostgreSQL logs, including pgaudit records, only exist as files on the data volume (/pgdata/pgNN/log/postgresql-<Day>.log, overwritten weekly). kubectl logs shows only Patroni, and cluster log shippers never see them. Operator 3.1.0's log collector fixes that: a Fluent Bit logs sidecar streams PostgreSQL and pgBackRest logs to stdout as JSON lines, and a logrotate sidecar caps the files on the data volume (100 MB, 7 kept).

What

New engine parameter logCollector.enabled:

Value New instance Existing instance
unset on unchanged (off for instances created before this)
true on on (rolling restart)
false off off (rolling restart if it was on)
  • Unset → the provider sends spec.logcollector with the image but without enabled; the operator turns it on when it creates the cluster and otherwise keeps the cluster's current state. So upgrading the provider doesn't restart existing instances. The operator resolves this in memory and doesn't write enabled back, so nothing conflicts with the provider's apply.
  • Image from a new fluentbit catalog entry (percona/fluentbit:5.1.1-1, the one in the 3.1.0 cr.yaml), so it can be overridden/mirrored. Explicitly enabling it without a catalog image is rejected by Validate.
  • Sidecars get requests 50m/64Mi and limits 350m/200Mi (the operator sets none).
  • UI: Collect logs toggle under Advanced Configuration, defaultValue: true on create and false in edit mode (edit mode leaves unset values undefined, so a true default would turn it on for existing instances on any save of that section).
  • README: Logs section and capability row.

Testing

  • Unit tests (parameter decoding, rendering incl. no-image cases, Validate), go test -race ./... and make lint pass.
  • On a throwaway k3d cluster with operator 3.1.0 and the exact block the provider renders:
    • new cluster, enabled unset → logs + logrotate sidecars;
    • existing cluster (created without it), block added with enabled unset → no sidecars, same pod (no restart);
    • existing cluster, enabled: true → sidecars added;
    • new cluster, enabled: false → sidecars removed;
    • kubectl logs <pod> -c logs shows PostgreSQL lines as JSON, including pgaudit records (AUDIT: SESSION,1,1,DDL,CREATE TABLE,...).

Known limitation

An instance created through the API with enabled unset has the collector on, but the edit form shows the toggle off; saving the Advanced Configuration section would then write false. Documented in the README (set enabled explicitly when creating through the API). Custom Fluent Bit outputs (S3, OTel) and logrotate overrides are left for a follow-up.

spron-in and others added 2 commits November 9, 2026 14:07
- pg-operator Helm dependency 3.0.0 -> 3.1.0
- Go module: the operator moved to github.com/percona/percona-postgresql-operator/v3
  in 3.1.0, so imports switch from the v2 pseudo-version to v3 v3.1.0. The
  provider sets crVersion from it, so instances are moved to crVersion 3.1.0.
- Version catalog: add the images certified with 3.1.0 (PostgreSQL 14.24-1,
  15.19-1, 16.15-1, 17.11.1-1, 18.6.1-1, pgBouncer 1.25.2-6, pgBackRest
  2.59.0-1) and make them the defaults; every bundle uses pgBouncer 1.25.2-6.
- PG_OPERATOR_VERSION 3.1.0 for CRDs and tests; upgrade tests start from 3.0.0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Sergey Pronin <sp@solanica.io>
…ances

Operator 3.1.0's log collector adds a Fluent Bit "logs" sidecar that streams
PostgreSQL and pgBackRest logs to stdout as JSON, and a "logrotate" sidecar
that caps the log files on the data volume. Without it, PostgreSQL logs
(including pgaudit records) only exist as files on the data volume.

engine.parameters.logCollector.enabled controls it. Unset, the provider sends
the logcollector block without enabled, so the operator turns it on for new
clusters and keeps existing clusters as they are: upgrading the provider
doesn't restart existing instances. The image comes from a new fluentbit
catalog entry; the sidecars get default requests and limits. The UI toggle
defaults to on when creating and to the spec's value when editing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Sergey Pronin <sp@solanica.io>
@spron-in
spron-in requested a review from a team as a code owner November 9, 2026 11:32
@spron-in
spron-in added this pull request to stack #92 November 9, 2026 11:46
spron-in and others added 2 commits November 10, 2026 14:12
Brings in pgHBA (#89), the PMM contract module (#88) and #93. The new
pg_hba code imported the operator's v2 module path; switch it to v3 to
match the 3.1.0 bump.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve conflicts with pgHBA from main: keep both engine parameters
(pgHBA, then logCollector) in the types, topology, Sync, Validate, tests
and README, and regenerate the provider spec.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	charts/provider-percona-postgresql/generated/provider-spec.yaml
#	go.mod
#	go.sum
#	internal/provider/backup_mirror.go
#	internal/provider/backup_mirror_test.go
#	internal/provider/provider.go
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
Base automatically changed from chore/bump-pg-operator-3.1.0 to main November 19, 2026 12:59
# Conflicts:
#	definition/versions.yaml
Signed-off-by: Oksana Grishchenko <oksana.grishchenko@percona.com>
@oksana-grishchenko
oksana-grishchenko merged commit 12b6707 into main Nov 19, 2026
11 checks passed
@oksana-grishchenko
oksana-grishchenko deleted the feat/logcollector branch November 19, 2026 13:18
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.

2 participants