Repository navigation
Reject invalid VMs in addNodesToKubernetesCluster instead of dropping them - #14833
bhouse-nexthop wants to merge 1 commit into
Conversation
… them addNodesToKubernetesCluster silently dropped VMs that failed validation and ran the add worker on the rest, so the call reported success for VMs that were never tried. | case | before | after | |---|---|---| | VM removed (expunged) | dropped | rejected | | template not found or deleted | dropped | rejected | | template not marked for CKS | dropped | rejected | | default NIC not in the cluster network | dropped | rejected | | VM has no default NIC | NullPointerException | rejected | | VM already in this cluster | dropped | rejected | - The whole request fails with one InvalidParameterValueException that names every invalid VM and why. - removeNodesFromKubernetesCluster is unchanged. Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14833 +/- ##
=========================================
Coverage 18.31% 18.32%
- Complexity 16642 16655 +13
=========================================
Files 5939 5939
Lines 537787 537791 +4
Branches 65932 65936 +4
=========================================
+ Hits 98510 98544 +34
+ Misses 428072 428045 -27
+ Partials 11205 11202 -3
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 KVM lab running a main (24.0) build that includes this change. Primary storage is Ceph RBD. The CKS cluster is Kubernetes 1.34.7, 1 control and 2 worker nodes, on its isolated network. The PR targets 4.22; I deployed a CirrOS VM (its template is not marked for CKS) on the cluster's network. Then I called Result: 12 of 12 checks passed (gates included).
Before this change, both VMs would have been dropped from the request and the call would have reported success without adding anything (#14832). The existing worker is reported twice: once because the CKS system VM template it runs from is not marked for CKS, and once because it is already in the cluster. Both reasons are true. The CirrOS VM was destroyed afterwards. Not tested: a VM with no default NIC, and a VM whose default NIC is on another network (unit tests only). |
Description
Fixes #14832
addNodesToKubernetesClusternow rejects the whole request when any VM is invalid, instead of dropping that VM and adding the rest.validateNodescollects every reason and throws oneInvalidParameterValueException, e.g.Unable to add the nodes to the Kubernetes cluster: VM <uuid> is deployed with template <uuid>, which is not marked for CKS; VM <uuid> does not have its default NIC in the Kubernetes cluster network <name>.removeNodesFromKubernetesClusteris unchanged.Related open PRs in the same code:
validateNodesre-add, dedup)validateNodes: keep #14796's signature, dedup andlistByVmIdloop, addinvalidNodes, and in that loop replacelogger.warn+validNodeIds.remove(id)withinvalidNodes.add(... mappedCluster.getUuid()). Its two "rejects" tests then expect the exception. Resolved and tested: 97/97 plugin tests pass.Types of changes
Bug Severity
How Has This Been Tested?
KubernetesClusterManagerImplTest: 10 new tests: one per case above (plus a purged-row fallback), plus a mixed list (one valid VM, two invalid; only the invalid ones are named), a valid list, and the remove path still dropping a missing VM.