Skip to content

[Bug]: Cluster stuck in "Setting up primary" when instance creation Job fails #11042

Description

@leonardoce

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.30.0-rc1

What version of Kubernetes are you using?

1.36

What is your Kubernetes environment?

Self-managed: kind (evaluation)

How did you install the operator?

YAML manifest

What happened?

When restoring or bootstrapping a cluster, if the instance creation Job exhausts its backoff limit and terminates with a BackoffLimitExceeded failure, the cluster remains stuck in the "Setting up primary" phase indefinitely.

The operator counts the failed Job as still running, so reconciliation keeps waiting on it forever without surfacing the failure. Operators have no indication that the restore has failed — the cluster simply never progresses.

Expected Behavior

When an instance creation Job reaches a terminal JobFailed condition, the cluster should transition to the unrecoverable phase with a clear reason pointing to the failed Job and its logs. Jobs that are still legitimately retrying within their backoff limit should be left untouched — only terminal failures should trigger this transition.

Cluster resource

Relevant log output

Code of Conduct

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

Activity

  1. self-assigned this
    on Jun 25, 2026
  2. dosubot commented on Jun 25, 2026

    @dosubot

    This issue is already being addressed in PR #11035, which introduces explicit detection of terminal JobFailed conditions (including BackoffLimitExceeded) and transitions the cluster to PhaseUnrecoverable with a clear failure reason pointing to the failed Job.

    The root cause is that the reconciliation loop's runningJobNames() guard historically relied on Status.Succeeded counts to determine Job completion — a terminal failure was indistinguishable from a still-running Job, causing the cluster to poll indefinitely at 5-second intervals [1].

    The fix adds a JobHasFailed(job) utility in pkg/utils/job_conditions.go that checks for the batchv1.JobFailed condition, and a failedJobNames() method to collect permanently failed Jobs. Failed Jobs are preserved for investigation rather than cleaned up [2].

    There's also a related feature request in #10733 proposing a Provisioning condition on cluster.status.conditions to surface provisioning failures (quota exceeded, admission denials, scheduling constraints) that occur before the Job even creates a Pod — complementary to this fix which handles failures after the Job has started running.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about cloudnative-pg with Dosu Add Dosu to your team

  3. added theissue type on Jun 25, 2026
  4. added this to the 1.30.0 milestone on Jun 25, 2026
  5. added 4 commits that reference this issue on Jun 26, 2026
    e494009
    811201c
    d5810d9
    cb0703f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛Something isn't working

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions