Skip to content

fix(restore): break certificate-wait deadlock in orphan-PVC restore - #11492

Merged
leonardoce merged 2 commits into
mainfrom
dev/11491
Sep 17, 2026
Merged

leonardoce merged 2 commits into
mainfrom
dev/11491

Conversation

@mnencia

@mnencia mnencia commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Restoring a multi-instance cluster from orphan PVCs could hang forever. A replica's bootstrap-instance init container waits for the certificate status before it can finish. The restore gate waits for that same init container to finish before the reconcile loop reaches the code that sets the certificate status. Neither side could move.

Set the certificate status right away, before the restore gate runs, so the init container's wait ends immediately and the gate sees it finish on the next pass.

The regression test runs both sides for real, in separate goroutines: the actual certificate wait and the actual restore gate. Without the fix it times out.

Closes #11491

Assisted-by: Claude

@mnencia
mnencia requested a review from a team as a code owner September 16, 2026 10:07
@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 16, 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

@mnencia

mnencia commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

/test

@github-actions

Copy link
Copy Markdown
Contributor

@armru

armru commented Sep 16, 2026

Copy link
Copy Markdown
Member

/test

@github-actions

Copy link
Copy Markdown
Contributor

mnencia and others added 2 commits September 17, 2026 12:23
Restoring a multi-instance cluster from orphan PVCs could hang
forever. A replica's bootstrap-instance init container waits for the
certificate status before it can finish. The restore gate waits for
that same init container to finish before the reconcile loop reaches
the code that sets the certificate status. Neither side could move.

Set the certificate status right away, before the restore gate runs,
so the init container's wait ends immediately and the gate sees it
finish on the next pass.

The regression test runs both sides for real, in separate goroutines:
the actual certificate wait and the actual restore gate. Without the
fix it times out.

Closes #11491

Assisted-by: Claude
Signed-off-by: Marco Nenciarini <[email protected]>
Setting up the PKI before the restore gate moved a failure of that step
out of createPostgresClusterObjects, which records it in the cluster
status as "Cannot create cluster objects". On the orphan-PVC path the
same failure, typically a user-specified CA secret that does not exist,
only surfaced as a reconcile error and left the phase untouched.

Register the same phase from the restore path so the status keeps
telling the user what is blocking the cluster.

Signed-off-by: Armando Ruocco <[email protected]>
@leonardoce
leonardoce merged commit 0d65c25 into main Sep 17, 2026
36 checks passed
@leonardoce
leonardoce deleted the dev/11491 branch September 17, 2026 12:26
cnpg-bot pushed a commit that referenced this pull request Sep 17, 2026
…11492)

Restoring a multi-instance cluster from orphan PVCs could hang forever.
A replica's bootstrap-instance init container waits for the certificate
status before it can finish. The restore gate waits for that same init
container to finish before the reconcile loop reaches the code that sets
the certificate status. Neither side could move.

Set the certificate status right away, before the restore gate runs, so
the init container's wait ends immediately and the gate sees it finish
on the next pass.

The regression test runs both sides for real, in separate goroutines:
the actual certificate wait and the actual restore gate. Without the fix
it times out.

Closes #11491

Assisted-by: Claude

Signed-off-by: Marco Nenciarini <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Co-authored-by: Armando Ruocco <[email protected]>
(cherry picked from commit 0d65c25)
leonardoce pushed a commit that referenced this pull request Sep 17, 2026
…11492)

Restoring a multi-instance cluster from orphan PVCs could hang forever.
A replica's bootstrap-instance init container waits for the certificate
status before it can finish. The restore gate waits for that same init
container to finish before the reconcile loop reaches the code that sets
the certificate status. Neither side could move.

Set the certificate status right away, before the restore gate runs, so
the init container's wait ends immediately and the gate sees it finish
on the next pass.

The regression test runs both sides for real, in separate goroutines:
the actual certificate wait and the actual restore gate. Without the fix
it times out.

Closes #11491

Assisted-by: Claude

Signed-off-by: Marco Nenciarini <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Co-authored-by: Armando Ruocco <[email protected]>
(cherry picked from commit 0d65c25)
(cherry picked from commit 4f1a9e9)
leonardoce pushed a commit that referenced this pull request Sep 17, 2026
…11492)

Restoring a multi-instance cluster from orphan PVCs could hang forever.
A replica's bootstrap-instance init container waits for the certificate
status before it can finish. The restore gate waits for that same init
container to finish before the reconcile loop reaches the code that sets
the certificate status. Neither side could move.

Set the certificate status right away, before the restore gate runs, so
the init container's wait ends immediately and the gate sees it finish
on the next pass.

The regression test runs both sides for real, in separate goroutines:
the actual certificate wait and the actual restore gate. Without the fix
it times out.

Closes #11491

Assisted-by: Claude

Signed-off-by: Marco Nenciarini <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Co-authored-by: Armando Ruocco <[email protected]>
(cherry picked from commit 0d65c25)
(cherry picked from commit 4f1a9e9)
(cherry picked from commit b68aaa7)
cnpg-bot pushed a commit to cloudnative-pg/api that referenced this pull request Sep 18, 2026
…loudnative-pg/cloudnative-pg#11492)

Restoring a multi-instance cluster from orphan PVCs could hang forever.
A replica's bootstrap-instance init container waits for the certificate
status before it can finish. The restore gate waits for that same init
container to finish before the reconcile loop reaches the code that sets
the certificate status. Neither side could move.

Set the certificate status right away, before the restore gate runs, so
the init container's wait ends immediately and the gate sees it finish
on the next pass.

The regression test runs both sides for real, in separate goroutines:
the actual certificate wait and the actual restore gate. Without the fix
it times out.

Closes cloudnative-pg/cloudnative-pg#11491

Assisted-by: Claude

Signed-off-by: Marco Nenciarini <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Co-authored-by: Armando Ruocco <[email protected]>

(cherry picked from commit cloudnative-pg/cloudnative-pg@0d65c25)
mnencia added a commit that referenced this pull request Sep 22, 2026
This reverts commit 0d65c25 (#11492).

No genuinely new Pod ever reaches the restore gate before the cluster
is marked initialized, so #11492 has no legitimate beneficiary: it
only changes where a stale bootstrap-instance init container gets
stuck. Before #11492, a stale join-role container parked on the
certificate wait (#11491). After it, the wait resolves immediately and
the same container proceeds into the join step instead, where it now
hangs dialing a primary with no running pod (#11503). The initdb-role
case (#11505) is unaffected either way, since initdb never waits on
certificate status.

Reverting restores the #11491 behavior; it does not fix the underlying
stale-container bug, which needs its own fix tracked in #11503.

Signed-off-by: Marco Nenciarini <[email protected]>
mnencia added a commit that referenced this pull request Sep 22, 2026
#11548)

This reverts commit 0d65c25 (#11492).

No genuinely new Pod ever reaches the restore gate before the cluster is
marked initialized, so #11492 has no legitimate beneficiary: it only
changes where a stale bootstrap-instance init container gets stuck.
Before #11492, a stale join-role container parked on the certificate
wait (#11491). After it, the wait resolves immediately and the same
container proceeds into the join step instead, where it now hangs
dialing a primary with no running pod (#11503). The initdb-role case
(#11505) is unaffected either way, since initdb never waits on
certificate status.

Reverting restores the #11491 behavior; it does not fix the underlying
stale-container bug, which needs its own fix tracked in #11503.

Signed-off-by: Marco Nenciarini <[email protected]>
mnencia added a commit that referenced this pull request Sep 22, 2026
cnpg-bot pushed a commit that referenced this pull request Sep 22, 2026
#11548)

This reverts commit 0d65c25 (#11492).

No genuinely new Pod ever reaches the restore gate before the cluster is
marked initialized, so #11492 has no legitimate beneficiary: it only
changes where a stale bootstrap-instance init container gets stuck.
Before #11492, a stale join-role container parked on the certificate
wait (#11491). After it, the wait resolves immediately and the same
container proceeds into the join step instead, where it now hangs
dialing a primary with no running pod (#11503). The initdb-role case
(#11505) is unaffected either way, since initdb never waits on
certificate status.

Reverting restores the #11491 behavior; it does not fix the underlying
stale-container bug, which needs its own fix tracked in #11503.

Signed-off-by: Marco Nenciarini <[email protected]>
(cherry picked from commit a6afa71)
mnencia added a commit that referenced this pull request Sep 23, 2026
#11548)

This reverts commit 0d65c25 (#11492).

No genuinely new Pod ever reaches the restore gate before the cluster is
marked initialized, so #11492 has no legitimate beneficiary: it only
changes where a stale bootstrap-instance init container gets stuck.
Before #11492, a stale join-role container parked on the certificate
wait (#11491). After it, the wait resolves immediately and the same
container proceeds into the join step instead, where it now hangs
dialing a primary with no running pod (#11503). The initdb-role case
(#11505) is unaffected either way, since initdb never waits on
certificate status.

Reverting restores the #11491 behavior; it does not fix the underlying
stale-container bug, which needs its own fix tracked in #11503.

Signed-off-by: Marco Nenciarini <[email protected]>
(cherry picked from commit a6afa71)
mnencia added a commit that referenced this pull request Sep 23, 2026
#11548)

This reverts commit 0d65c25 (#11492).

No genuinely new Pod ever reaches the restore gate before the cluster is
marked initialized, so #11492 has no legitimate beneficiary: it only
changes where a stale bootstrap-instance init container gets stuck.
Before #11492, a stale join-role container parked on the certificate
wait (#11491). After it, the wait resolves immediately and the same
container proceeds into the join step instead, where it now hangs
dialing a primary with no running pod (#11503). The initdb-role case
(#11505) is unaffected either way, since initdb never waits on
certificate status.

Reverting restores the #11491 behavior; it does not fix the underlying
stale-container bug, which needs its own fix tracked in #11503.

Signed-off-by: Marco Nenciarini <[email protected]>
(cherry picked from commit a6afa71)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-requested ◀️ This pull request should be backported to all supported releases ok to merge 👌 This PR can be merged release-1.28 release-1.30

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: bootstrap-instance deadlocks with the operator on a multi-instance restore from orphaned PVCs

4 participants