Repository navigation
Conversation
The operator rotates pods itself and only waits for the Patroni role label after recreating a pod. A broken sidecar image therefore rolls through all members of a cluster. With enable_rolling_update_readiness_check, the rolling update waits until each recreated pod has been ready for rolling_update_min_ready_time and stops if a container restarts or the pod does not become available. Later syncs postpone the rolling update while an already rotated pod is not available. A new spec change marks all pods again, so reverting a broken image still rolls out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
monotek
marked this pull request as ready for review
November 3, 2026 13:04
monotek
requested review from
FxKu,
Jan-M,
hughcapet,
idanovinda,
jopadi and
mikkeloscar
as code owners
November 3, 2026 13:04
This branch has not been deployed
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.
Problem description
The operator rotates Postgres pods itself (the StatefulSet uses
updateStrategy: OnDelete). After deleting a pod,recreatePodsonly waits for the new pod to get its Patroni role label, and Patroni sets that label from inside the Spilo container. Pod readiness and sidecar containers are never checked.So a broken sidecar image is rolled to every member of a cluster. We hit this with an exporter sidecar whose new image crashlooped:
-1was recreated, and its exporter started crashlooping.-2, although-1's exporter had already restarted several times.-0to-1, recreated-0, and emittedRolling update done.The result: every pod was NotReady. A single rotated member should have been enough to notice, but the operator kept going.
This PR adds an opt-in readiness check for rolling updates. It is off by default, so current behaviour does not change.
#1424 raised the concern that waiting for ready pods could keep users from fixing a broken config. That does not happen here: any new spec change, such as reverting the broken image, marks every pod for rotation again, so no pod counts as already rotated and the rollout proceeds.
TestSyncStatefulSetRollingUpdateReadinessCheckcovers that case.Summary
Two new options in the
kubernetessection:enable_rolling_update_readiness_check(defaultfalse)rolling_update_min_ready_time(default30s): how long a recreated pod must stay Ready before the rollout continues. A container crash resets the Ready condition and with it this time, so a sidecar that crashes shortly after starting is caught too.Within one rollout:
Across syncs: a stopped rollout leaves the remaining pods annotated with
zalando-postgres-operator-rolling-update-required. Without a check, the next sync would rotate the next pod anyway. So:MigrateMasterPod, used when draining a node, is unchanged.Evidence
Unit tests at the levels the existing tests already use:
After: with it enabled, the rollout stops after the first pod. I also disabled the sync check temporarily, and
TestSyncStatefulSetRollingUpdateReadinessCheckfailed as it should.go test ./...passes.Merge Danger
Door: two-way
Opt-in and off by default. Turning it off restores the current behaviour.
Blast Radius: none by default; stalled rollouts when enabled
With the check enabled, a pod that is NotReady for an unrelated reason holds the rollout until it becomes ready, for example a lagging replica when
enable_readiness_probeis on. Within one rollout, each pod also takes up torolling_update_min_ready_timelonger.Linked issues
recreatePodscall.Checklist
Thanks for submitting a pull request to the Postgres Operator project.
Please, ensure your contribution matches the following items:
acid.zalan.doapi package.🤖 Generated with Claude Code