Skip to content

fix(restore): stop the orphan-PVC restore gate waiting on our own init containers - #11549

Merged
mnencia merged 1 commit into
mainfrom
dev/11503
Oct 2, 2026
Merged

mnencia merged 1 commit into
mainfrom
dev/11503

Conversation

@armru

@armru armru commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

A backup tool restores an instance Pod with its PVC, so the Pod keeps its bootstrap-instance init container. It reruns on live data and never ends. The restore gate waited for it, so the stale Pod was never deleted.

The gate now skips the operator's own init containers (bootstrap-controller and bootstrap-instance), like it already skips sidecars.

Related: #11491
Closes #11503


When a backup tool restores an instance Pod together with its PVC, the Pod still carries the bootstrap-instance init container it was created with. Kubernetes only knows that the container belongs to the Pod, not that it already did its job on the volume before the backup, so it runs it again on data that is already live. A join never finds a primary to stream from, so the container never terminates.

The restore gate waited for every non-sidecar init container in every instance Pod before deleting the stale Pods, so on such a Pod it waited on bootstrap-instance forever and the deletion that would have replaced the Pod never ran. The gate exists for the init containers a backup tool adds to copy the PVC content back, so it now ignores the operator's own bootstrap-controller and bootstrap-instance containers, together with the sidecars it already skipped.

Verified on kind against a 2-instance cluster whose PVCs, secrets, service account and RBAC were kept while the Cluster was deleted, and whose replica Pod was recreated without owner with a sleep 60 init container in front of its original bootstrap-instance, as a backup tool would do. With main the operator loops on "init container running, waiting for completion" for bootstrap-instance and the cluster never comes up. With this change the stale Pod is deleted as soon as the tool's init container exits and the primary is back within a minute. The recreated replica then fails because the stale join rerun had already renamed its data directory aside, which is #11505 and out of scope here.

@armru
armru requested a review from a team as a code owner September 22, 2026 15:50
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.29 release-1.30 labels Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@armru

armru commented Sep 22, 2026

Copy link
Copy Markdown
Member Author

/test

@github-actions

Copy link
Copy Markdown
Contributor

@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Sep 22, 2026
…t containers

When a backup tool restores an instance Pod together with its PVC, the
Pod still carries the bootstrap-instance init container it was created
with. Kubernetes only knows that the container belongs to the Pod, not
that it already did its job on the volume before the backup, so it runs
it again on data that is already live. A join never finds a primary to
stream from and an initdb reruns on populated data, so the container
never terminates.

The restore gate waited for every non-sidecar init container in every
instance Pod before deleting the stale Pods. On such a Pod it waited on
bootstrap-instance forever, and the deletion that would have replaced
the Pod never ran. The gate exists for the init containers a backup tool
adds to copy the PVC content back, so it now ignores the operator's own
bootstrap-controller and bootstrap-instance containers together with the
sidecars it already skipped.

Closes #11503

Signed-off-by: Armando Ruocco <[email protected]>
@mnencia mnencia added do not backport This PR must not be backported - it will be in the next minor release and removed backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30 labels Oct 2, 2026
@mnencia mnencia changed the title fix(restore): stop the orphan-PVC restore gate waiting on our own init containers fix(restore): skip bootstrap-instance in the orphan-PVC restore gate Oct 2, 2026
@mnencia mnencia changed the title fix(restore): skip bootstrap-instance in the orphan-PVC restore gate fix(restore): stop the orphan-PVC restore gate waiting on our own init containers Oct 2, 2026
@mnencia
mnencia merged commit 887bffe into main Oct 2, 2026
38 checks passed
@mnencia
mnencia deleted the dev/11503 branch October 2, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not backport This PR must not be backported - it will be in the next minor release ok to merge 👌 This PR can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Orphan-PVC restore deletes a restored Pod's stale init container too late, gate deadlocks on it first

4 participants