retina icon indicating copy to clipboard operation
retina copied to clipboard

fix: select node IP by address type

Open immanuwell opened this issue 6 months ago • 3 comments

Description

Tiny follow-up for the node reconciler. If status.addresses has Hostname before InternalIP, Retina used the hostname as the cached node IP. That breaks lookups by the real node IP, kinda sneaky.

Now it picks InternalIP first, then ExternalIP, then any parseable IP. If there is no IP, it logs and skips the cache update.

Related Issue

Related: #1541 Follow-up to #1569

Repro

  1. Reconcile a Node with addresses ordered like this:
    • Hostname: test-node
    • InternalIP: 10.0.0.4
  2. Ask the cache for 10.0.0.4.
  3. Before this fix it returns nil, because the node was cached with test-node. not great

The new test covers this exact case.

Checklist

  • [x] I have read the contributing documentation.
  • [x] I signed and signed-off the commits (git commit -S -s ...).
  • [x] I have correctly attributed the author(s) of the code.
  • [x] I have tested the changes locally.
  • [x] I have followed the project style.
  • [x] I have added tests.

Testing Completed

go test ./pkg/controllers/daemon/node ./pkg/controllers/cache ./pkg/controllers/daemon/service ./pkg/controllers/daemon/namespace ./pkg/controllers/daemon/metricsconfiguration

Also checked go test ./pkg/controllers/daemon/..., but local envtest is missing /usr/local/kubebuilder/bin/etcd.

immanuwell avatar May 27 '26 07:05 immanuwell

@microsoft-github-policy-service agree [company="Immanuel Tikhonov"]

immanuwell avatar May 27 '26 08:05 immanuwell

@microsoft-github-policy-service agree

immanuwell avatar May 27 '26 08:05 immanuwell

@microsoft-github-policy-service agree company="Immanuel Tikhonov"

immanuwell avatar May 27 '26 08:05 immanuwell