Skip to content

Normalize k0s node names before drain, cordon, etc - #1095

Merged
kke merged 1 commit into
k0sproject:mainfrom
kv1sidisi:fix-node-name-case
Jun 24, 2026
Merged

kke merged 1 commit into
k0sproject:mainfrom
kv1sidisi:fix-node-name-case

Conversation

@kv1sidisi

Copy link
Copy Markdown
Contributor
  • Normalize node names to lowercase before kubectl maintenance and readiness checks.
  • Catch case-only hostname duplicates earlier and keep reset flows aligned with the same node identity.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes how k0sctl derives the Kubernetes node name from a host by normalizing hostnames to lowercase before running kubectl-based readiness checks and node maintenance operations, and by validating hostname uniqueness using the normalized node identity.

Changes:

  • Introduces Host.KubernetesNodeName() (lowercased hostname) and switches kubectl node operations (drain/cordon/uncordon/delete/taints) to use it.
  • Updates node readiness checks and reset flows to reference the normalized node name.
  • Updates host validation to detect case-only hostname duplicates earlier; adds a unit test for KubernetesNodeName().

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/node/statusfunc.go Uses normalized node name for kubectl get node readiness checks and related error messages.
pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/host.go Adds KubernetesNodeName() and applies it across kubectl node maintenance helpers.
pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/host_test.go Adds unit test ensuring node name normalization behavior.
phase/validate_hosts.go Validates hostname uniqueness using the normalized Kubernetes node name.
phase/reset_workers.go Uses normalized node name when draining/deleting worker nodes during reset.
phase/reset_controllers.go Uses normalized node name when draining/deleting controller-worker nodes during reset.
phase/gather_k0s_facts.go Logs worker-join readiness checks using the normalized node name.
phase/gather_facts.go Normalizes configured hostname override to lowercase when setting host metadata.

๐Ÿ’ก Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread phase/validate_hosts.go Resolved
@kke
kke force-pushed the fix-node-name-case branch from f2cdec5 to 4dd6a41 Compare June 15, 2026 12:08
@kke

kke commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

The commit needs to be signed off

Lowercases/normalizes k0s node names before maintenance operations so node lookups match the kubelet-reported names.

Co-authored-by: kv1sidisi <lyapunovvadim5002@gmail.com>
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
@kke
kke force-pushed the fix-node-name-case branch from 4dd6a41 to 503b779 Compare June 24, 2026 08:32
@kke kke changed the title Normalize k0s node names before maintenance Normalize k0s node names before drain, cordon, etc Jun 24, 2026
@kke
kke merged commit 28a0774 into k0sproject:main Jun 24, 2026
45 checks passed
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
k0sctl 0.31.1

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## Notice

The next release will contain #1092 only which is a significant refactoring to migrate the transport package [rig](https://github.com/k0sproject/rig) from v0.x to v2.0.0 - if issues surface, please report them and roll back to this v0.31.1 version.

## What's Changed
* Bump actions/checkout from 6 to 7 by @dependabot[bot] in k0sproject/k0sctl#1105
* Normalize k0s node names before drain, cordon, etc by @kv1sidisi in k0sproject/k0sctl#1095
* Bump github.com/k0sproject/rig from 0.21.10 to 0.21.11 by @dependabot[bot] in k0sproject/k0sctl#1107

## New Contributors
* @kv1sidisi made their first contribution in k0sproject/k0sctl#1095

**Full Changelog**: k0sproject/k0sctl@v0.31.0...v0.31.1

### SHA256 Checksums

```
c7dc5cdc7f8c006249d573229302612b8ef323ef4faff6a68ebe8c4aba83772d *k0sctl-linux-amd64
9107ce95f3762b2afbd0e5b9c7d4145e5749b36f3e1976c91873d04f6ae4f98f *k0sctl-linux-arm64
c7a09db15db08e238ecec548582f6045bf2fed4e418b3fb3f577f7dca277a2fa *k0sctl-linux-arm
659b4f308e5cbf8b8fcb9780c8f78675a39626a5c8918a94c9cce127d6e58b44 *k0sctl-linux-riscv64
77f83e76e0dafc372cda969c6e2206230900e83397b384c23868b323adcc1f96 *k0sctl-win-amd64.exe
dda7dd02d9a9c962e8685f46e03715aac0c22c1c2a0b761dbee675e3bc4eb7f0 *k0sctl-darwin-amd64
1554b0a6643af6ef63c66d47c12e704e5e0f86d6480e8479f0a68dc2c179cd1a *k0sctl-darwin-arm64
```
</pre>
  <p>View the full release notes at <a href="https://github.com/k0sproject/k0sctl/releases/tag/v0.31.1">https://github.com/k0sproject/k0sctl/releases/tag/v0.31.1</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!13292
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants