Repository navigation
make lazy upgrade adhere maintenance windows - #3204
Conversation
…ternal pod object because in the new code we check it after calling the function
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved rotation and maintenance-window regressions can defer required restarts, strand pending upgrades, or restart a primary without a switchover.
6 open issues
Preserve mandatory restart flags during image updates · New Reconcile image drift for unannotated pods · New Keep deferred replicas available as switchover candidates · New Use valid non-wrapping maintenance windows in tests · New Separate image rollout requirements from non-rollout changes · New Check incoming maintenance windows before permitting version rollouts · New
What changed in this PR
This PR makes lazy Spilo upgrades use enabled maintenance windows, while preserving deferred rotation when no windows are configured.
Changes:
- Distinguishes lazy upgrades from mandatory restarts through pod annotations.
- Filters pending lazy rotations according to maintenance windows.
- Extends end-to-end coverage and documents the updated behavior.
| File | Description |
|---|---|
pkg/cluster/util.go |
Extracts maintenance-window availability checks. |
pkg/cluster/sync.go |
Filters pending rotations using lazy-upgrade policy. |
pkg/cluster/resources.go |
Defines the lazy-upgrade annotation value. |
pkg/cluster/pod.go |
Classifies rotation reasons and stores annotation values. |
pkg/cluster/connection_pooler.go |
Adapts pooler restart checks to string flags. |
pkg/cluster/cluster.go |
Includes image differences in container comparisons. |
e2e/tests/test_e2e.py |
Tests maintenance-window rotation and resets synchronous mode. |
e2e/tests/k8s_api.py |
Adds a helper to read rotation annotations. |
docs/administrator.md |
Explains maintenance-aware lazy upgrades. |
Review effort: Balanced
| func (c *Cluster) getRollingUpdateReason(cmp *compareStatefulsetResult) string { | ||
| // if the only reason is a Spilo image update and lazy update is enabled | ||
| // provide a different message so a different pod annotation is used | ||
| imageDiffOnly := len(cmp.reasons) == 1 && strings.Contains(cmp.reasons[0], "image does not match the current one") |
There was a problem hiding this comment.
@copilot we can add more checks inside getRollingUpdateReason but I would not change the current compareStatefulSet logic to not make the code more complex than it already is. Note, that image updates are managed centrally by the DBaaS team, while other updates are done by the teams. It's very unlikely that both image and other changes fall into one sync.
Updated maintenance window definitions to use fixed hours instead of dynamic time calculations. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Polina Bungina <27892524+hughcapet@users.noreply.github.com>
|
👍 |
|
👍 |


While lazy upgrade are nice to save us from too many switchovers it becomes annoying when rolling out bugfixes in an entire fleet. Sure, we can switch it off an on, but then the rotation might not be carried out at the right time for some clusters.
Therefore, this PR proposes a solution in between. If maintenance windows are enabled and defined delay the next rolling update until that period. If no maintenance windows are configure the lazy upgrade behaves as before - waiting until the next K8s rotation (could be weeks).