Repository navigation
Count added nodes when scaling a Kubernetes cluster down - #14837
bhouse-nexthop wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14837 +/- ##
============================================
+ Coverage 18.32% 18.34% +0.02%
- Complexity 16648 16699 +51
============================================
Files 5939 5939
Lines 537799 537922 +123
Branches 65935 65960 +25
============================================
+ Hits 98546 98697 +151
+ Misses 428043 427999 -44
- Partials 11210 11226 +16
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:
|
|
Lab test on a 4.22-based build (8e994c8, this PR plus the related CKS PRs): KVM, isolated network, cluster with 1 control, 4 CKS-created workers and 2 nodes added with addNodesToKubernetesCluster (size 6).
|
060a029 to
53c65e6
Compare
Follow-up to "Count added nodes when scaling a Kubernetes cluster down", for its amended upstream version (apache#14837). - Before scaling, recount the cluster's worker, control and etcd nodes from its VMs (validateAndSyncWorkerNodeCount). If the stored counts have drifted, correct them together with the cores and memory. A size passed back unchanged only repairs the stored count; any other size on a drifted cluster is refused with the size to scale to first. - nodeids may only name CKS-created worker nodes. Control and etcd nodes are rejected in the manager and again in the worker. - Autoscaling minsize cannot be lower than the number of added nodes. - Clusters created before the control node flag existed: their first VMs are the control nodes and are never picked for scale-down. - New iscontrolnode on the cluster VM response. The UI hides the delete-node button for control, etcd and added nodes. Bundle adaptations: our scale-down still prefers worker VMs that are down, but sorts only the removable workers, after the unflagged control VMs are skipped by creation order. The recount runs after the check that the cluster is still in the state the request was accepted in, so it never corrects a cluster another operation has taken. Signed-off-by: Brad House <bhouse@nexthop.ai>
Follow-up to "Count added nodes when scaling a Kubernetes cluster down", for its amended upstream version (apache#14837). - Before scaling, recount the cluster's worker, control and etcd nodes from its VMs (validateAndSyncWorkerNodeCount). If the stored counts have drifted, correct them together with the cores and memory. A size passed back unchanged only repairs the stored count; any other size on a drifted cluster is refused with the size to scale to first. - nodeids may only name CKS-created worker nodes. Control and etcd nodes are rejected in the manager and again in the worker. - Autoscaling minsize cannot be lower than the number of added nodes. - Clusters created before the control node flag existed: their first VMs are the control nodes and are never picked for scale-down. - New iscontrolnode on the cluster VM response. The UI hides the delete-node button for control, etcd and added nodes. Bundle adaptations: our scale-down still prefers worker VMs that are down, but sorts only the removable workers, after the unflagged control VMs are skipped by creation order. The recount runs after the check that the cluster is still in the state the request was accepted in, so it never corrects a cluster another operation has taken. Signed-off-by: Brad House <bhouse@nexthop.ai>
|
Lab re-run of the updated change on a 4.22-based build (94c33ae): KVM, isolated network. Cluster with 1 control and 4 CKS-created workers, plus 2 nodes added with addNodesToKubernetesCluster (size 6).
Drift repair. Drift was simulated in the database the way the old no-op scale-down left it: the stored size lowered, and cores/memory lowered by the same number of workers.
|
The cluster size includes nodes added with addNodesToKubernetesCluster,
but scale-down only counted CKS-created workers. With added nodes
present, a scale-down removed too few nodes or none at all
("No nodes to remove"), still recorded the new size, and later
scale-ups waited forever for a Ready count that could not match.
- Scale-down by size removes CKS-created workers until created + added
workers equals the requested size.
- Every scale first checks the stored worker, control and etcd counts
against the cluster's VMs. If they drifted it corrects them and
recomputes cores and memory from each VM's offering, so clusters
damaged by the old behaviour are fixed by the next scale.
The API checks use the same count from the VMs. A size equal to the
stored one (the UI always sends it) is treated as unchanged; any
other size on a drifted cluster is rejected until it is corrected,
as the caller's intent is ambiguous. Clusters whose control node
flags were never set (created before 4.16) keep the stored counts.
- Reject a size or autoscaling minsize below the number of added
nodes; scaling never removes them.
- Scale nodeids only takes CKS-created workers. Added, control and
etcd nodes were skipped or removed without updating the counts.
removeNodesFromKubernetesCluster removes added nodes.
- UI: no per-node delete button for added, control or etcd nodes;
the VM list now reports iscontrolnode.
- Document that size and minsize count added nodes and which
nodeids are valid.
- Unit tests for each case.
Signed-off-by: Brad House <bhouse@nexthop.ai>
53c65e6 to
e3187d1
Compare
Follow-up to "Repair CKS size drift; reject control and etcd nodes in scale", for the next amendment of apache#14837. When the stored node counts have drifted, the scale worker no longer adds the missing nodes' share to the stored cores and memory. It recomputes them from the cluster's VMs, each by its own service offering, using the VM's details for a custom offering. Stored totals that were already wrong are therefore corrected, not carried forward. If the offering of any VM can't be read, the counts are still corrected but the cores and memory are left as they are. Signed-off-by: Brad House <bhouse@nexthop.ai>
Follow-up to "Repair CKS size drift; reject control and etcd nodes in scale", for the next amendment of apache#14837. When the stored node counts have drifted, the scale worker no longer adds the missing nodes' share to the stored cores and memory. It recomputes them from the cluster's VMs, each by its own service offering, using the VM's details for a custom offering. Stored totals that were already wrong are therefore corrected, not carried forward. If the offering of any VM can't be read, the counts are still corrected but the cores and memory are left as they are. Signed-off-by: Brad House <bhouse@nexthop.ai>
|
Follow-up on the drift repair, now that it recomputes capacity from the VMs. Tested on a main-based build (2583bb7, which has the same change as the 4.22 line): KVM, cluster with 1 control and 2 workers on a 2 vCPU/4096 MB offering, plus 2 added nodes, one on that offering and one on a custom offering at 2 vCPU/3072 MB. "Real" is the sum of cpunumber/memory over the cluster's VMs from listVirtualMachines.
Each repair logs |
Description
A CKS cluster's
sizeincludes nodes added withaddNodesToKubernetesCluster, but scale-down only counted CKS-created workers. With added nodes present, scale-down removed too few nodes or none ("No nodes to remove"), still saved the new size, and a later scale-up waited until timeout for a Ready count that could not match.size; on a drifted cluster "3 → 4" could mean add or remove, so don't guessminsize, below the number of added nodes (API check plus a worker check)nodeidsonly takes CKS-created workers; reject added, control and etcd nodes, and removing every workeriscontrolnodenodeidssize,minsizeandnodeidsdocsScale-up was already right when the stored size matches the nodes: it creates
size - nodeCountVMs and waits forcontrol + sizeReady nodes. With the count re-derived first, that is now always the real total.Drifted cluster (e.g. stored size 5, 6 real workers): any scale that keeps size 5 (or passes 6, or only changes the offering) corrects it to 6. Asking for another size first is rejected with a message saying to correct it. After that, requests are exact.
Fixes #14836
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
nodeidswith added/control/etcd/unknown nodes or all workerskubernetes-servicemodule unit testsnodeidsandminsizechecks still to be re-runHow did you try to break this feature and the system with this change?
nodeidspath: corrected too.scaleClustertests need the new count check stubbed (doNothing().when(scaleWorker).validateAndSyncWorkerNodeCount()); with that all module tests pass.