fix(hetzner): truncate schematic label to 63 chars and expand ~ in kubeconfig path#4647
fix(hetzner): truncate schematic label to 63 chars and expand ~ in kubeconfig path#4647
Conversation
…beconfig path Agent-Logs-Url: https://github.com/devantler-tech/ksail/sessions/91b58726-f6a6-49a0-80dc-e3ae777e4be9 Co-authored-by: devantler <26203420+devantler@users.noreply.github.com>
✅MegaLinter analysis: Success✅ Linters with no issuesactionlint, git_diff, hadolint, jscpd, jsonlint, lychee, markdown-table-formatter, markdownlint, prettier, prettier, stylelint, syft, trivy-sbom, trufflehog, v8r, v8r, yamllint See detailed reports in MegaLinter artifacts
|
There was a problem hiding this comment.
Pull request overview
Fixes two Hetzner/Talos update-path bugs that prevented ksail cluster update from successfully finding/creating the autoscaler-related secrets and snapshot resources by ensuring Hetzner label constraints and kubeconfig path resolution are handled correctly.
Changes:
- Truncate Talos factory schematic IDs to Hetzner’s 63-character label value limit via
SchematicLabelValue()and use it consistently for snapshot label creation and label-selector queries. - Expand
~in kubeconfig paths before canonicalization in the Hetzner Talos provisioner’s secret-ensuring helpers. - Add focused unit tests covering schematic truncation behavior and ensuring snapshot lookup uses the truncated label value.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/svc/provisioner/cluster/talos/provisioner_hetzner.go | Expands ~ before EvalCanonicalPath when creating kubeclients for Hetzner autoscaler-related secrets. |
| pkg/svc/provider/hetzner/snapshot.go | Applies schematic label truncation for snapshot labels and snapshot lookup selectors. |
| pkg/svc/provider/hetzner/snapshot_test.go | Adds coverage ensuring SHA256-length schematic IDs are truncated in label selectors and snapshot reuse works. |
| pkg/svc/provider/hetzner/labels.go | Introduces SchematicLabelValue() and documents Hetzner label value length constraint. |
| pkg/svc/provider/hetzner/labels_test.go | Adds table-driven tests for SchematicLabelValue() truncation behavior. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |

Two bugs prevent
ksail cluster updatefrom creating the autoscaler config secret on Hetzner clusters.Schematic label exceeds Hetzner's 63-char limit
Talos factory schematic IDs are SHA256 hex digests (64 chars). Hetzner Cloud label values are capped at 63 chars, so the label selector is rejected.
SchematicLabelValue()tolabels.gothat truncates to 63 charssnapshot.gofor both label creation and selector queries~not expanded beforeEvalCanonicalPathensureHcloudSecretandensureAutoscalerSecretpass~/.kube/configdirectly toEvalCanonicalPath, which callsfilepath.Abs— this does not expand~, producing<cwd>/~/.kube/config.fsutil.ExpandHomePathbeforeEvalCanonicalPathin both functions, matching the existing pattern inwriteKubeconfig