Skip to content

fix(switchover) bypass spec.unschedulable when checking if a node is cordoned - #10069

Open
enneitex wants to merge 2 commits into
cloudnative-pg:mainfrom
enneitex:fix/node-tainted
Open

enneitex wants to merge 2 commits into
cloudnative-pg:mainfrom
enneitex:fix/node-tainted

Conversation

@enneitex

@enneitex enneitex commented Feb 25, 2026 •

Copy link
Copy Markdown

Fixes #7799

The goal is to not trigger a switchover when a node is cordoned

When a user runs kubectl cordon, it adds two things to a node:

  • spec.unschedulable: true
  • a taint with the key node.kubernetes.io/unschedulable

Even when adding DRAIN_TAINTS="ToBeDeletedByClusterAutoscaler,karpenter.sh/disrupted,karpenter.sh/disruption" whitout node.kubernetes.io/unschedulable, a switchover will happen because of line https://github.com/cloudnative-pg/cloudnative-pg/blob/main/internal/controller/replicas.go#L193 who checks for spec.unschedulable.

The solution is to ignore this field as it is redundant with the taint.
I'm not aware of a scenario where spec.unschedulable is set without the associated taint but if there is a valid case, then I can rework this PR to add a new env var so a user can chose to bypass or not spec.unschedulable

@enneitex
enneitex requested a review from a team February 25, 2026 13:04
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Feb 25, 2026
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.25 release-1.28 labels Feb 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@dosubot dosubot Bot added the bug 🐛 Something isn't working label Feb 25, 2026
@legrandlegrand

Copy link
Copy Markdown

Hello,
I would like it for prod 😬
This may help bypassing replica PDB non respect, and limit downtime during K8S rollouts to a single switchover (after replicas drain)
Regards
PAscal

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Linked issue missing.

Reference one in the PR body using a keyword (Closes / Fixes / Resolves / Refs / See) followed by #<issue_id> or owner/repo#<issue_id>.

Alternatively, apply the no-issue label to skip this check.

@enneitex

enneitex commented Jul 1, 2026

Copy link
Copy Markdown
Author

There is an issue linked.

@legrandlegrand

Copy link
Copy Markdown

Fixes #7799

@Melchior01

Copy link
Copy Markdown

Hello, we’d really benefit from getting this change merged. Is there anything I can do to help move it forward?

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

Labels

backport-requested ◀️ This pull request should be backported to all supported releases bug 🐛 Something isn't working release-1.28 release-1.30 size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Node cordon (unschedulable taint) causes a switchover

5 participants