Repository navigation
Only let removeNodesFromKubernetesCluster remove added nodes - #14802
bhouse-nexthop wants to merge 1 commit into
Conversation
removeNodesFromKubernetesCluster only checked that each VM exists and that the caller can operate on it. Any VM id was handed to the remove worker, which drains, kubeadm-resets and deletes it from Kubernetes, revokes its port forwarding rules and lowers the cluster node count. | node id passed | before | after | |---|---|---| | VM not in any cluster | processed, node count lowered | rejected | | VM of another cluster | processed, that cluster's PF rules revoked | rejected | | control node | drained and reset, SSH rule revoked | rejected | | etcd node | processed | rejected | | CKS-managed worker | reset but VM left running | rejected | | node added with addNodesToKubernetesCluster | removed | removed | - New validateNodesRemovable(): each id must map to this cluster with external_node set and neither control_node nor etcd_node set. - Throws InvalidParameterValueException naming the VM and cluster uuid. - Rejects the call on ExternalManaged clusters via isCommandSupported, like the other cluster commands do. - Unit tests for each case above. Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14802 +/- ##
============================================
+ Coverage 18.31% 18.34% +0.02%
- Complexity 16642 16676 +34
============================================
Files 5939 5939
Lines 537787 537846 +59
Branches 65932 65944 +12
============================================
+ Hits 98510 98651 +141
+ Misses 428072 427979 -93
- Partials 11205 11216 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Tested on a nested KVM lab running 4.22.1.1-nexthop (a 4.22.1.1-based build that carries this change along with the other open CKS fixes): 3 KVM hosts, Ceph RBD primary storage, isolated network. CKS cluster on Kubernetes v1.32.3 (Calico).
After the three rejected calls, the rules and vm_map rows were identical, and every node stayed Ready. |
|
The one remaining CI failure is The CI on this PR was already re-run once, so I'm leaving it as is. |
Description
Fixes #14801
removeNodesFromKubernetesClusternow only removes nodes that were added withaddNodesToKubernetesCluster.scaleKubernetesClusterremoveVirtualMachinesFromKubernetesClustervalidateNodesRemovable(): each id must have akubernetes_cluster_vm_maprow in this cluster withexternal_nodeset and neithercontrol_nodenoretcd_nodeset.InvalidParameterValueException, naming the VM and cluster uuid.isCommandSupportedcheck added, like the other cluster commands.Related open PRs touching the same files, which merge cleanly with this one:
validateNodesfor add)Types of changes
Bug Severity
How Has This Been Tested?
KubernetesClusterManagerImplTest: 10 new tests cover the accepted case, not a member, control, etcd, external+control, external+etcd, CKS-managed worker, mixed list, and throughremoveNodesFromKubernetesCluster(control node, ExternalManaged cluster). 39/39 pass.