Skip to content

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

Closed

Description

@mnencia

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.

I have read the troubleshooting guide

  • I have read the troubleshooting guide and I think this is a new bug.

I am running a supported version of CloudNativePG

  • I have read the troubleshooting guide and I think this is a new bug.

Version

trunk (main). The fix that caused this (#11450) is not in any released version yet.

What version of Kubernetes are you using?

any. This is a control-flow bug, not tied to a Kubernetes version.

What is your Kubernetes environment?

Self-managed: kind (evaluation)

How did you install the operator?

Other

What happened?

Restore a Cluster from orphaned PVCs (PVCs and Cluster CR recreated, CR status empty, the normal state after any snapshot or backup-tool restore) with 2 or more instances. The cluster gets stuck for good, not just slow.

Two code paths wait on each other:

  1. Reconcile runs reconcileRestoredCluster before createPostgresClusterObjects (internal/controller/cluster_controller.go:358 and :371). The restore path calls ensureInitContainersAreCompleted (internal/controller/cluster_restore.go:359), which requeues and returns early if any instance pod's init container is not Terminated yet.
  2. That early return skips createPostgresClusterObjects too, so setupPostgresPKI never runs. That call is what writes Cluster.Status.Certificates.
  3. A replica's bootstrap-instance init container calls WaitForClusterCertificates (pkg/management/client.go:175, added by fix(bootstrap): wait for certificate status before refreshing secrets #11450). It polls Status.Certificates.ServerTLSSecret with no timeout, and only exits once that field is set.
  4. Step 3 needs step 2 to run. Step 2 needs step 3's container to finish first. Neither happens.

WaitForClusterCertificates's own comment says the operator never waits on this pod before writing the status. In this restore path, it does.

Expected: the cluster comes up like any other restore.

Relevant log output

# operator, repeats every 5s, never moves past this:
found orphan pvcs, trying to restore the cluster
init container running, waiting for completion  podName=<replica> initContainerName=bootstrap-instance

# replica's bootstrap-instance container, last line it ever logs:
Waiting for the operator to write the certificate status

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    bug 🐛
    on Sep 16, 2026
  2. self-assigned this
    on Sep 16, 2026
  3. added a commit that references this issue on Sep 17, 2026
    4f1a9e9
  4. added 2 commits that reference this issue on Sep 17, 2026
    b68aaa7
    fb655a4
  5. added a commit that references this issue on Sep 17, 2026
    0d65c25
  6. added a commit that references this issue on Sep 18, 2026
    5d0a2b8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions