Skip to content

Taint a CKS node whose VM CloudStack knows is down - #14754

Open
bhouse-nexthop wants to merge 1 commit into
apache:mainfrom
bhouse-nexthop:cks-out-of-service-taint
Open

bhouse-nexthop wants to merge 1 commit into
apache:mainfrom
bhouse-nexthop:cks-out-of-service-taint

Conversation

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator

Description

Fixes #14753

When a CKS node VM goes down, Kubernetes keeps its volumes attached and stateful pods stay stuck until the node returns. This adds the non-graceful node shutdown taint node.kubernetes.io/out-of-service=nodeshutdown:NoExecute to the node while CloudStack knows its VM is down, and removes it when the VM runs again.

what how
setting cloud.kubernetes.cluster.node.out.of.service.taint.enabled, global, dynamic, default false
where the existing CKS state scanner, for Running and Alert clusters on Kubernetes 1.26+
taint when the VM is Stopped, Destroyed, Expunging
never taint when the VM is Running, Starting, Stopping, Migrating, Unknown, Shutdown, Error, backup/restore states
left alone clusters being scaled, upgraded, stopped or having nodes removed (VM and cluster state re-read just before each kubectl call)
how kubectl runs over SSH on any running control node, same addressing as the upgrade worker; no running control node means skip quietly
untaint when the VM is Running again; works even if the setting was turned off since
bookkeeping tainted VM ids in a cluster detail (outOfServiceTaintedVms), written before tainting so a lost result still gets cleaned up

Why only those states: a host that is merely disconnected leaves its VMs Running in the DB, and the VM may well still be running. Stopped is only set once CloudStack has stopped the VM or HA has decided the host is down. Force-detaching a volume that is still in use risks corruption, so anything less certain is skipped.

Why default off: the taint makes Kubernetes attach the node's volumes elsewhere, which is only safe where "Stopped" really means powered off (e.g. host HA with fencing). Operators should opt in.

Types of changes

  • New feature (non-breaking change which adds functionality)

Feature/Enhancement Scale or Bug Severity

  • Minor

How Has This Been Tested?

test result
KubernetesClusterNodeTaintWorkerTest (14 new) pass
all KubernetesCluster*Test in the plugin pass
live cluster not yet

When a node VM of a running CKS cluster goes down, Kubernetes keeps its
volumes attached and its stateful pods stuck until the node returns. The
node.kubernetes.io/out-of-service taint (non-graceful node shutdown,
default on from 1.26, GA in 1.28) lets Kubernetes force-detach the
volumes and reschedule the pods.

- New setting cloud.kubernetes.cluster.node.out.of.service.taint.enabled
  (default false)
- The state scanner, for Running and Alert clusters on 1.26 or later:
  - taints a node whose VM is Stopped, Destroyed or Expunging
  - removes the taint once the VM is Running again
  - does nothing for transitional or unknown states
- VM and cluster state are re-read right before each kubectl call, so a
  cluster being scaled, upgraded, stopped or having nodes removed is left
  alone
- kubectl runs over SSH on any running control node; with none running
  the scan skips quietly
- Tainted VM ids are kept in a cluster detail, written before tainting,
  so the taint is removed even after the setting is turned off, the
  cluster is restarted or a taint result is lost; a taint is re-sent
  until it is confirmed and every 10 minutes after

Signed-off-by: Brad House <bhouse@nexthop.ai>
@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.61111% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.82%. Comparing base (2737087) to head (edc797b).

Files with missing lines Patch % Lines
...ctionworkers/KubernetesClusterNodeTaintWorker.java 82.53% 9 Missing and 13 partials ⚠️
...bernetes/cluster/KubernetesClusterManagerImpl.java 0.00% 16 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14754      +/-   ##
============================================
+ Coverage     20.80%   20.82%   +0.01%     
- Complexity    20919    20961      +42     
============================================
  Files          6053     6054       +1     
  Lines        548451   548595     +144     
  Branches      78719    73309    -5410     
============================================
+ Hits         114128   114224      +96     
- Misses       420958   421002      +44     
- Partials      13365    13369       +4     
Flag Coverage Δ
uitests 3.86% <ø> (ø)
unittests 22.25% <73.61%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

Lab test: passed

Tested on a nested KVM lab (3 hosts, Ceph RBD) running a main (24.0.0-SNAPSHOT) build with this commit, and cloud.kubernetes.cluster.node.out.of.service.taint.enabled=true. Kubernetes v1.33.13. The CloudStack CSI driver v3.0.0 provided the volumes.

Single control node, 2 workers. A StatefulSet (1 replica, 1Gi PVC) ran on worker A. Worker A was then stopped with stopVirtualMachine forced=true, outside CKS.

time event
+0s VM Stopped
+10s cluster Alert, node has node.kubernetes.io/out-of-service=nodeshutdown:NoExecute
+71s db-0 Running on worker B, VolumeAttachment moved to worker B, the data written before the stop is still on the volume
start VM, +32s node Ready, taint removed, cluster back to Running, tainted-VMs detail cleared

HA: 3 control nodes, 2 workers.

step result
stop the first control node tainted within 16s (kubectl ran through another control node)
also stop a worker while it is down tainted within 22s
start both both taints removed, cluster back to Running within 46s, all 5 nodes Ready

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CKS: add the out-of-service taint to a node whose VM is down

1 participant