fix(talos-cluster): guard per-node hostname patch against empty/whitespace strings#64
Merged
Merged
Conversation
…space strings The per-node hostname patch added in v1.6.0 (#57) guarded only on `hostname != null`, so an explicit empty or whitespace-only string — e.g. from an unset template variable — passed the check and pushed `machine.network.hostname: ""` to the node instead of being treated as "no hostname". Guard now uses `trimspace(...) != ""` with `try()` covering the null case, and the patch value is trimmed; blank hostnames are now a no-op (Talos keeps its auto-generated name), matching null. Also document the `hostname` input: a new "Node Hostnames" section in the module README and expanded `control_plane`/`workers` variable descriptions note that hostnames apply at first boot only — Talos cannot rename an already-running node (`static hostname already set`), so a live cluster must be wiped and re-provisioned to change a hostname. Follow-up to #57. Verified with `terraform validate`, `terraform fmt`, and a `terraform console` truth-table check of the new guard.
Merged
jfreed-dev
added a commit
that referenced
this pull request
Jun 19, 2026
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.
Follow-up to #57 (per-node Talos hostnames), addressing two items found in a max-effort code review of that change.
Problem
The hostname patch from #57 guarded only on
hostname != null:An explicit empty string (e.g.
hostname = var.cp_hostnamewhere the var is unset →"") passes!= null, so the module pushedmachine.network.hostname: ""to the node instead of treating it as "no hostname override".Fix
main.tf, both control-plane and worker blocks): guard ontrimspace(...) != "", withtry()covering the null case, and trim the value used in the patch. Blank/whitespace-only hostnames are now a no-op (Talos keeps its auto-generated name), identical to null.hostnameinput was undocumented beyond the type:static hostname already set), so a live cluster must be wiped and re-provisioned to change a hostname.control_plane/workersvariable descriptions (and the synced terraform-docs input table) with the same notes.[Unreleased].Verification
Guard truth table via
terraform console:try(trimspace(x), "") != ""nullfalse""false" "false"turing-cp1"trueAlso ran
terraform fmt -check(clean) andterraform validate(success) on the module.🤖 Generated with Claude Code