Skip to content

[Bug]: Cluster reconciliation loop gets stuck when scaling replicas due to failed snapshot recovery jobs #7793

Open

Description

@jmealo

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.

Contact Details

[email protected]

Version

1.26 (latest patch)

What version of Kubernetes are you using?

1.31

What is your Kubernetes environment?

Cloud: Azure AKS

How did you install the operator?

YAML manifest

What happened?

When scaling up a CloudNativePG cluster, if the snapshot recovery job for a new replica fails, the controller can get stuck in a reconciliation loop. The cluster status remains in "Creating a new replica", and even after manually deleting the failed job, the cluster does not return to a healthy state. This prevents any further scaling operations and can lead to production issues if not manually resolved.

To Reproduce

Steps to reproduce the behavior:

  1. Have a healthy CNPG cluster.
  2. Attempt to scale up the number of instances (e.g., from 9 to 10).
  3. Induce a failure in the snapshot recovery process for the new replica. This could be due to a missing PVC, an invalid volume snapshot, or other underlying infrastructure issues that make the job unscheduleable.
  4. Observe that a snapshot-recovery job is created.
  5. The job fails and the pod for the job remains in a Pending state because the required PVCs are not found.
  6. The cluster status becomes Creating a new replica and gets stuck there.
  7. Manually delete the failed job using kubectl delete job <job-name>.
  8. Observe that the cluster status does not change and remains stuck.

Expected behavior

  1. After a snapshot recovery job fails a certain number of times, the controller should abandon the attempt for that specific instance and either:
    a. Try creating the replica again from scratch (e.g., via streaming replication).
    b. Mark the instance as failed and allow the cluster to return to a Ready state with the existing healthy replicas.
  2. Deleting a failed job should immediately trigger the controller to re-evaluate the cluster state and either retry the operation or clear the stuck phase.

Actual behavior

The controller remains stuck in the Creating a new replica phase, even after the failed job is deleted. The only way to recover is to manually patch the cluster's status to remove the phase and phaseReason fields.

Workaround

The following manual intervention was required to unstick the cluster:

  1. Delete the stuck snapshot-recovery job:

    kubectl delete job <cluster-name>-<instance-id>-snapshot-recovery -n <namespace>
  2. Clear the cluster phase and reason from the status:

    kubectl patch cluster <cluster-name> -n <namespace> --type='json' -p='[
      {"op": "remove", "path": "/status/phase"},
      {"op": "remove", "path": "/status/phaseReason"}
    ]' --subresource=status

Supporting data

  • Cluster Status when stuck:

    status:
      phase: Creating a new replica
      phaseReason: Creating replica <cluster-name>-<instance-id>-snapshot-recovery
  • Job Pod Events:

    Events:
      Type     Reason            Age                     From               Message
      ----     ------            ----                    ----               -------
      Warning  FailedScheduling  3m40s (x201 over 7h3m)  default-scheduler  0/90 nodes are available: persistentvolumeclaim "<pvc-name>" not found.
    

System information

  • CloudNativePG version: 1.26.0
  • Kubernetes version: 1.31
  • Cloud provider: Azure (AKS)

Additional context

The use of Jobs for recovery is not immediately obvious to end-users (due to how instance pods are scheduled without using deployments), making troubleshooting difficult. Improving the controller's resilience to such failures and documenting the recovery process would be highly beneficial. I'd like to try to clean up parts of my run book to add to a troubleshooting section while we still have some rough edges.

Cluster resource

Relevant log output

Code of Conduct

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

Activity

  1. added
    triage
    on Jun 9, 2025
  2. dosubot commented on Sep 8, 2025

    @dosubot

    Hi, @jmealo. I'm Dosu, and I'm helping the cloudnative-pg team manage their backlog and am marking this issue as stale.

    Issue Summary:

    • You reported a bug in CloudNativePG v1.26 where scaling up a cluster hangs if a snapshot recovery job for a new replica fails.
    • The cluster remains stuck in "Creating a new replica" status indefinitely.
    • Manual deletion of the failed job does not resolve the issue or allow further scaling.
    • Expected behavior is for the controller to abandon or retry the failed replica creation and update the cluster status accordingly.
    • No further comments or activity have been recorded on this issue.

    Next Steps:

    • Please let me know if this issue is still relevant with the latest version of CloudNativePG by commenting here to keep the discussion open.
    • Otherwise, this issue will be automatically closed in 7 days.

    Thank you for your understanding and contribution!

  3. jmealo commented on Sep 8, 2025

    @jmealo
    ContributorAuthor

    This is still relevant. I have a PR open to fix it, but I haven't had a chance to test it in a cluster yet, I've only run the unit tests. It hasn't passed the E2E tests (not sure how to get those triggered). #7794

  4. github-actions commented on Nov 14, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open for 60 days with no activity.

  5. github-actions commented on Nov 29, 2025

    @github-actions
    Contributor

    This issue was closed because it has been inactive for 14 days since being marked as stale.

  6. added
    bug 🐛
    and removed
    triage
    on Dec 12, 2025
  7. moved this from Done to In Development in CloudNativePG operator developmenton Dec 12, 2025
  8. added this to the Now milestone on Dec 12, 2025
  9. added a commit that references this issue on Feb 18, 2026
    40b6605
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛no-stale

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions