cloudnative-pg / cloudnative-pg/cloudnative-pg

[Bug]: failover can be silently reverted

Open
#11,346 0 comments 1 reaction 1 assignee Claimed by @leonardoce View on GitHub
bug :bug: triage
Dominant language
Go
Stars
9.3k
Forks
759
Avg merge
2d 6h
Merged PRs (30d)
44

Description

### Is there an existing issue already for this bug?

- [x] 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

- [x] I have read the troubleshooting guide and I think this is a new bug.

### I am running a supported version of CloudNativePG

- [x] I have read the troubleshooting guide and I think this is a new bug.

### Contact Details

leonardo.cecchi@enterprisedb.com

### Version

1.30.0

### 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 a failover was in progress and the cluster's target primary was set to the internal "pending" marker, two separate reconciliation bugs could prevent it from ever completing:

1. The reconcile loop treated the pending marker like any other in-progress switchover and short-circuited every pass with a flat 1-second requeue, never actually checking whether the failover was ready to complete. This could cause the failover to stall indefinitely.
2. Independently, the status-update logic didn't recognize the pending marker as a special value — it looked for a running instance matching that marker, found none, and concluded the target primary was invalid. It then reset TargetPrimary back to the (unhealthy) current primary, silently undoing the failover that was already underway.

### Cluster resource

```shell

```

### Relevant log output

```shell

```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.