Avoid switchover after migrating a single-pod cluster - #3187
Open
Shubham-Padkonde wants to merge 1 commit into
Open
Shubham-Padkonde wants to merge 1 commit into
Shubham-Padkonde wants to merge 1 commit into
Conversation
Leave the replica candidate unset for single-pod clusters so migration returns after recreating the master instead of contacting its stale IP. Add migration regressions and document the recreate-only path. Signed-off-by: Shubham Padkonde <shubhampadkonde12@gmail.com>
Shubham-Padkonde
requested review from
FxKu,
Jan-M,
hughcapet,
idanovinda,
jopadi and
mikkeloscar
as code owners
September 17, 2026 21:13
Author
|
The COMPR/pr-labels check requires one of the project classification labels. Could a maintainer add |
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
Migrating a single-pod cluster off an unschedulable node recreates the master, then attempts a Patroni switchover to itself using the deleted pod's IP.
masterCandidatePodstarts asoldMaster, making the existing recreate-only branch unreachable.Leave the candidate unset until a replica is selected. Single-pod clusters now take the existing recreate-and-return path; clusters with replicas still select a candidate and switch over to it.
Added tests exercise successful single-pod relocation without any Patroni request, deletion failure, relocation to the same node, and successful switchover to a healthy replica. The migration parameter documentation now explains the single-pod behavior and downtime.
Validation on Linux with Go 1.26.4:
make testpasses across the repository.go test -race ./pkg/cluster -run 'TestMigrate|TestGetSwitchoverCandidate' -count=1passes.make localbuilds the operator.gofmtandgit diff --checkpass.The tests use the Kubernetes fake client, pod events, and a mocked Patroni HTTP client. Live Kubernetes node rotation and database end-to-end tests were not run.
AI assistance: Codex (GPT-6) assisted with investigation, code, tests, documentation and this description.
Linked issues
Fixes #3059. Proposed approach posted in the issue before implementation.
Checklist