Skip to content

make lazy upgrade adhere maintenance windows - #3204

Merged
FxKu merged 13 commits into
masterfrom
lazy-upgrade-during-windows
Oct 27, 2026
Merged

FxKu merged 13 commits into
masterfrom
lazy-upgrade-during-windows

Conversation

@FxKu

@FxKu FxKu commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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).

@FxKu FxKu added this to the 2.1.0 milestone Oct 20, 2026

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.

🟡 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
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

Comment thread pkg/cluster/pod.go
Comment thread pkg/cluster/sync.go Outdated
Comment thread pkg/cluster/sync.go Outdated
Comment thread e2e/tests/test_e2e.py Outdated
Comment thread pkg/cluster/pod.go
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")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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.

Comment thread pkg/cluster/util.go Outdated
FxKu and others added 5 commits October 22, 2026 11:52
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>
Comment thread pkg/cluster/sync.go Outdated
Co-authored-by: Polina Bungina <27892524+hughcapet@users.noreply.github.com>
@FxKu

FxKu commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

👍

@FxKu FxKu added major Major feature changes or updates, e.g. feature rollout to a new country, new API calls. and removed minor labels Oct 27, 2026
@FxKu

FxKu commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

👍

@FxKu
FxKu merged commit 61e4c9f into master Oct 27, 2026
15 of 18 checks passed
@FxKu
FxKu deleted the lazy-upgrade-during-windows branch October 27, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major Major feature changes or updates, e.g. feature rollout to a new country, new API calls.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants