Skip to content

pillar: use wait helper for k8s node name - #6173

Merged
milan-zededa merged 2 commits into
lf-edge:masterfrom
eriknordmark:waitfornodename
Jul 20, 2026
Merged

milan-zededa merged 2 commits into
lf-edge:masterfrom
eriknordmark:waitfornodename

Conversation

@eriknordmark

@eriknordmark eriknordmark commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow-up cleanup to #6121, which added the WaitForNodeName /
NodeNameFromDeviceName helpers in utils/wait and left a TODO to convert the
remaining open-coders.

domainmgr and zedkube each opened their own EdgeNodeInfo subscription,
open-coded the DeviceName → Kubernetes-node-name normalization
(strings.ReplaceAll(strings.ToLower(name), "_", "-")), and then kept the
subscription alive in their run loops without ever re-deriving the name.
EdgeNodeInfo is static for the lifetime of a boot, so the long-lived
subscription is unnecessary — a single up-front wait yields everything.

Both agents now resolve the node name once via the shared helpers:

  • domainmgr uses WaitForNodeName.
  • zedkube uses the new WaitForEdgeNodeInfo, which returns the whole
    types.EdgeNodeInfo so zedkube also gets the DeviceID (node UUID) it uses
    for its k8s node-uuid lookups, and still fires its on-boot side effects
    (uncordon watcher, Longhorn disk reservation).

The derivation now lives in exactly one Go location, NodeNameFromDeviceName.
Its shell twin convert_to_k8s_compatible (cluster-utils.sh, used for the
k3s node name and the Longhorn node name) can't import Go, so the two are now
cross-referenced by name in both directions to keep them in sync.

No functional change intended — same node name/UUID resolution, same startup
gating, just consolidated.

How to test and validate this PR

  • make -C pkg/pillar builds and go vet pass for both the default and
    HV=k (-tags k) tag sets; the change is compile-validated for the
    kubevirt build that actually exercises this code.
  • End-to-end: bring up an EVE-k device/cluster and confirm domainmgr and
    zedkube reach steady state — the node registers under the derived name,
    and node-scoped operations (cordon/drain, Longhorn disk reservation) work as
    before.

Validated on a live amd64 EVE-k device (this branch, HV=k, under eden/QEMU):
domainmgr logged Got nodeName <uuid>, zedkube logged
got nodeName <uuid> nodeuuid <uuid> (both name and UUID from the single
WaitForEdgeNodeInfo struct), no checkAndSaveEdgeNodeInfo lines remained, and
k3s registered the node Ready/control-plane under that derived name.

Changelog notes

None (internal refactor; no user-facing changes).

PR Backports

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 device
  • I've tested my PR on arm64 device
  • I've written the test verification instructions
  • I've set the proper labels to this PR
  • I've checked the boxes above, or I've provided a good reason why I didn't
    check them.

Validated on amd64 EVE-k (see the results under "How to test" above). arm64 not
exercised; this is an architecture-independent Go refactor of the agent startup
path, also compile- and vet-validated for the default and HV=k tag sets.

domainmgr and zedkube each opened their own EdgeNodeInfo subscription
and open-coded the DeviceName-to-node-name normalization, then kept the
subscription alive without ever re-deriving. EdgeNodeInfo is static for
the lifetime of a boot, so a single up-front wait is sufficient.

Both agents now resolve the Kubernetes node name once through the shared
wait helpers: domainmgr via WaitForNodeName, and zedkube via the new
WaitForEdgeNodeInfo, which returns the whole EdgeNodeInfo so zedkube also
gets the node UUID it needs. The normalization now lives only in
NodeNameFromDeviceName, cross-referenced with its shell counterpart
convert_to_k8s_compatible in cluster-utils.sh.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 22.99%. Comparing base (3d35218) to head (a193846).
⚠️ Report is 14 commits behind head on master.

Files with missing lines Patch % Lines
pkg/pillar/cmd/zedkube/zedkube.go 0.00% 14 Missing ⚠️
pkg/pillar/utils/wait/waitfor.go 0.00% 13 Missing ⚠️
pkg/pillar/cmd/domainmgr/domainmgr.go 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6173      +/-   ##
==========================================
+ Coverage   22.62%   22.99%   +0.37%     
==========================================
  Files         506      516      +10     
  Lines       93219    94894    +1675     
==========================================
+ Hits        21088    21822     +734     
- Misses      70408    71161     +753     
- Partials     1723     1911     +188     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The newly added exported WaitForEdgeNodeInfo trips revive's "exported"
rule (name stutters as wait.WaitForEdgeNodeInfo), which fails the Yetus
gate. Add the same //revive:disable-next-line:exported directive already
used on WaitForNodeName; the WaitFor* prefix is kept deliberately to
match the pre-existing WaitForVault/WaitForOnboarded helpers in this
package.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread pkg/pillar/utils/wait/waitfor.go Resolved
@milan-zededa
milan-zededa merged commit baa2c20 into lf-edge:master Jul 20, 2026
72 of 77 checks passed
@eriknordmark
eriknordmark deleted the waitfornodename branch July 21, 2026 05:55
@eriknordmark eriknordmark added the stable Should be backported to stable release(s) label Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stable Should be backported to stable release(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants