Skip to content

[Bug]: Operator initiates failover without waiting for kubelet to confirm pod is not ready #10423

Closed as not planned

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.

Contact Details

No response

Version

trunk (main)

What version of Kubernetes are you using?

No response

What is your Kubernetes environment?

Cloud: Azure AKS

How did you install the operator?

No response

What happened?

The operator decides to initiate failover based solely on its own HTTP health check to the pod IP (30s timeout in rawInstanceStatusRequest). It does not check whether the kubelet has also detected the failure by marking the pod as NotReady.

This can cause premature failovers in environments where pods can be temporarily frozen without crashing (e.g. Azure VM live migration). During a VM migration, the node is paused for a few seconds (typically 8-30s). If a reconciliation cycle happens to run during the freeze, the operator's HTTP request times out and it initiates failover, even though the kubelet is also frozen and still considers the pod Ready. When the VM migration completes, the old primary comes back with PostgreSQL still running as primary.

The operator already collects IsPodReady from the kubelet's ContainersReady condition in the PostgresqlStatus struct (pkg/postgres/status.go:103), but does not use it in the failover decision path.

Proposed fix

In reconcileTargetPrimaryFromPods (replicas.go), before initiating failover, check that the current primary's pod has been marked NotReady by the kubelet. If the operator's HTTP check fails but IsPodReady is still true, the operator should wait rather than immediately triggering failover.

This naturally provides ~30s of protection (readiness probe period=10s, default failure threshold=3), which covers most VM live migration windows.

Cluster resource

Relevant log output

Code of Conduct

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

Activity

  1. added
    triage
    and removed
    triage
    on Apr 8, 2026
  2. added theissue type on Apr 8, 2026
  3. github-actions commented on Jun 8, 2026

    @github-actions
    Contributor

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

  4. added
    bug 🐛
    and removed on Jun 21, 2026
  5. github-actions commented on Sep 25, 2026

    @github-actions
    Contributor

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

  6. github-actions commented on Oct 9, 2026

    @github-actions
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stalebug 🐛

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions