postgres-operator/pkg/cluster
Alec Thomas 513291c58d Create critical-op PDB on-demand to avoid false monitoring alerts
The critical-op PodDisruptionBudget was previously created permanently,
but its selector (critical-operation=true) matched no pods during normal
operation. This caused false alerts in monitoring systems like
kube-prometheus-stack because the PDB expected healthy pods but none
matched.

Changes:
- Modified syncCriticalOpPodDisruptionBudget to check if any pods have
  the critical-operation label before creating/keeping the PDB
- PDB is now created on-demand when pods are labeled (e.g., during
  major version upgrades) and deleted when labels are removed
- Updated majorVersionUpgrade to explicitly create/delete the PDB
  around the critical operation for immediate protection
- Removed automatic critical-op PDB creation from initial cluster setup
- Added test to verify on-demand PDB creation and deletion behavior,
  including edge cases for idempotent create/delete operations

The explicit PDB creation in majorVersionUpgrade ensures immediate
protection before the critical operation starts. The sync function
serves as a safety net for edge cases like bootstrap (where Patroni
applies labels) or operator restarts during critical operations.

Fixes #3020
2026-01-02 16:05:32 -05:00
..
cluster.go fix switchover schedule tests (#2995) 2025-12-11 10:22:40 +01:00
cluster_test.go fix switchover schedule tests (#2995) 2025-12-11 10:22:40 +01:00
connection_pooler.go Ensure podAnnotations are removed from pods if reset in the config (#2826) 2025-01-24 16:53:14 +01:00
connection_pooler_new_test.go Connection pooler for replica (#1127) 2020-11-13 14:52:21 +01:00
connection_pooler_test.go reflect linter feedback, remove unused argumnents and redundant type from arrays (#2739) 2024-08-27 17:56:07 +02:00
database.go stop retention user cleanup early again when DB connection attempt fails (#2999) 2025-12-10 10:01:07 +01:00
exec.go fix golangci-lint issues (#2715) 2024-08-14 12:54:44 +02:00
filesystems.go reflect change in github url (#496) 2019-02-25 11:26:55 +01:00
k8sres.go Fix Sidecar without image specification issue (#2977) 2025-12-09 09:37:11 +01:00
k8sres_test.go Fix Sidecar without image specification issue (#2977) 2025-12-09 09:37:11 +01:00
majorversionupgrade.go Create critical-op PDB on-demand to avoid false monitoring alerts 2026-01-02 16:05:32 -05:00
pod.go bump dependencies and reflect linter suggestions (#2963) 2025-10-16 10:23:36 +02:00
pod_test.go fix switch over candidate retrieving (#2760) 2024-11-01 17:06:20 +01:00
resources.go Create critical-op PDB on-demand to avoid false monitoring alerts 2026-01-02 16:05:32 -05:00
streams.go do not remove publications of slot defined in manifest (#2868) 2025-02-26 17:31:37 +01:00
streams_test.go fix flaky comparison unit test of retruned errors (#2822) 2024-12-19 17:35:01 +01:00
sync.go Create critical-op PDB on-demand to avoid false monitoring alerts 2026-01-02 16:05:32 -05:00
sync_test.go Create critical-op PDB on-demand to avoid false monitoring alerts 2026-01-02 16:05:32 -05:00
types.go Critical operation PDB (#2830) 2025-01-29 12:41:08 +01:00
util.go upgrade Go from 1.23.4 to 1.25.0 (#2945) 2025-08-19 14:40:39 +02:00
util_test.go do not remove publications of slot defined in manifest (#2868) 2025-02-26 17:31:37 +01:00
volumes.go upgrade Go from 1.23.4 to 1.25.0 (#2945) 2025-08-19 14:40:39 +02:00
volumes_test.go Add support for EBS CSI Driver (#2677) 2024-12-19 12:32:09 +01:00