feat(cnpg): add WAL, checkpoint and monitoring parameters#95
Open
Starefossen wants to merge 3 commits into
Open
feat(cnpg): add WAL, checkpoint and monitoring parameters#95Starefossen wants to merge 3 commits into
Starefossen wants to merge 3 commits into
Conversation
mortenlj
approved these changes
May 20, 2026
f85e7eb to
36d7f4d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Expands CNPG-backed Postgres cluster tuning by deriving additional PostgreSQL configuration parameters (WAL, checkpoints, monitoring, and HA-only group commit) from the cluster’s requested resources and HA setting.
Changes:
- Compute and set additional CNPG
PostgresConfiguration.Parameters(e.g.,max_wal_size,wal_buffers,checkpoint_timeout,track_io_timing, HA-onlycommit_delay/commit_siblings). - Refactor parameter generation to accept the full
PostgresClusterinstead of separate audit/memory inputs. - Extend the CNPG basic e2e Chainsaw test to assert creation of monitoring resources.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/e2e/postgres-cnpg-basic/chainsaw-test.yaml | Adds assertions for PodMonitor and PrometheusRule resources. |
| internal/controller/resourcecreator/cnpg.go | Adds resource-derived CNPG Postgres parameter tuning (WAL/checkpoints/monitoring/HA group commit). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+79
to
+104
| - name: Assert PodMonitor created | ||
| try: | ||
| - assert: | ||
| resource: | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: PodMonitor | ||
| metadata: | ||
| name: mydb | ||
| namespace: pg-cnpg-team | ||
| labels: | ||
| prometheus: tenant | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| cnpg.io/cluster: mydb | ||
| podMetricsEndpoints: | ||
| - port: metrics | ||
| - name: Assert PrometheusRule created | ||
| try: | ||
| - assert: | ||
| resource: | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: PrometheusRule | ||
| metadata: | ||
| name: mydb | ||
| namespace: pg-cnpg-team |
Comment on lines
+103
to
+104
| name: mydb | ||
| namespace: pg-cnpg-team |
Comment on lines
239
to
+259
| @@ -248,24 +249,64 @@ func makeCNPGPostgresParameters(audit *data_nais_io_v1.PostgresAudit, memory res | |||
| maintenanceWorkMem = maxMaintenanceWorkMemBytes | |||
| } | |||
|
|
|||
| // WAL sizing: ~2% of disk, clamped between 1GB and 8GB | |||
| maxWalSize := diskBytes / 50 | |||
| if maxWalSize < 1*1024*1024*1024 { | |||
| maxWalSize = 1 * 1024 * 1024 * 1024 | |||
| } | |||
| if maxWalSize > 8*1024*1024*1024 { | |||
| maxWalSize = 8 * 1024 * 1024 * 1024 | |||
| } | |||
Test Results4 tests 4 ✅ 1m 0s ⏱️ Results for commit e1387fe. ♻️ This comment has been updated with latest results. |
36d7f4d to
a8edef3
Compare
Expand CNPG PostgreSQL tuning based on upstream best practices: - WAL: max_wal_size (2% of disk, 1-8GB), wal_compression=zstd, wal_buffers (1/32 of shared_buffers) - Checkpoints: checkpoint_timeout=10min, bgwriter_lru_maxpages=200 - Monitoring: track_io_timing=on, pg_stat_statements.track=all - HA-only: commit_delay/commit_siblings for group commit - Remove shared_preload_libraries (CNPG manages it automatically) All dynamic values are computed from cluster shape (memory, disk, highAvailability) — no hardcoded sizes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add assertions for PodMonitor (with prometheus:tenant label and correct selector) and PrometheusRule creation in the postgres-cnpg-basic E2E test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix PodMonitor/PrometheusRule E2E assertions: CNPG uses the CR's own namespace (not pg-<team>) and names are prefixed with pg- - Use enforceMinimum2GiDisk() for WAL sizing to align with actual PVC size Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bc33969 to
e1387fe
Compare
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.
Expand CNPG PostgreSQL tuning based on upstream best practices:
wal_buffers (1/32 of shared_buffers)
All dynamic values are computed from cluster shape (memory, disk,
highAvailability) — no hardcoded sizes.
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com