Repository navigation
Reset a previously joined VM before adding it to a CKS cluster - #14796
Open
bhouse-nexthop wants to merge 1 commit into
Open
bhouse-nexthop wants to merge 1 commit into
bhouse-nexthop wants to merge 1 commit into
Conversation
A VM removed from a CKS cluster with removeNodesFromKubernetesCluster
and added again with addNodesToKubernetesCluster never rejoins:
- /home/cloud/success is left on the VM, so setup-kube-system and
deploy-kube-system exit with "Already provisioned!"
- the add job then waits for a Ready node until it times out
Changes:
- add worker: the SSH step that clears the cloud-init semaphores now
also resets what the first boot left behind, so setup-kube-system
can run again:
- deletes the marker
- stops a deploy-kube-system left retrying an old join
- unmounts and deletes /mnt/k8sdisk and /aux-dwnld (VR mode leaves
binaries there and the next mv into it fails)
- disables kubelet (a crash-looping kubelet makes the binary copy
fail with ETXTBSY); setup-kube-system enables it again
- kubeadm reset -f, if kubeadm is installed
- the step now runs after the user data update, right before the
reboot, instead of during validation. Best effort, logged on
failure, as before
- validateNodes: reject a VM that is mapped to any Kubernetes cluster,
not only the target one, so the reset can't wipe a node still in use.
A leftover row for a deleted cluster does not block the VM.
Duplicate VM ids are dropped, so a VM is not reset twice in one add
- unit tests for both
Why on add and not on remove:
- covers VMs already removed by older releases, which carry the marker
- covers removals that skipped the worker step (no SSH rule found)
- add always has SSH to the VM; remove may not
Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14796 +/- ##
============================================
+ Coverage 18.31% 18.32% +0.01%
- Complexity 16642 16652 +10
============================================
Files 5939 5939
Lines 537787 537800 +13
Branches 65932 65933 +1
============================================
+ Hits 98510 98568 +58
+ Misses 428072 428020 -52
- Partials 11205 11212 +7
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:
|
2 tasks done
Collaborator
Author
|
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).
|
This was referenced Nov 23, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A VM removed from a CKS cluster and added again never rejoins.
/home/cloud/successstays on the VM, so the join scripts exit withAlready provisioned!and the add times out.deploy-kube-system, clears/mnt/k8sdiskand/aux-dwnld, disables kubelet and runskubeadm reset -fif kubeadm is installedsetup-kube-systemrun cleanly again on a VM that was set up beforevalidateNodes: reject a VM mapped to any live Kubernetes cluster, not only the target one; drop duplicate idsKubernetesClusterVmMapDao.listByVmIdWhy on add and not on remove:
Every step is best effort and logged, the same as the existing semaphore cleanup.
Fixes: #14795
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
KubernetesClusterAddWorkerTest(new): reset command, SSH success, failure and exceptionKubernetesClusterManagerImplTest:validateNodeswith no mapping, a live mapping, a stale mapping, stale plus live rows, duplicate idskubernetes-servicemodule testsbash -nanddash -nNot yet run on a live cluster.
How did you try to break this feature and the system with this change?