fix: select node IP by address type
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
- Reconcile a Node with addresses ordered like this:
Hostname: test-nodeInternalIP: 10.0.0.4
- Ask the cache for
10.0.0.4. - 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.
@microsoft-github-policy-service agree [company="Immanuel Tikhonov"]
@microsoft-github-policy-service agree
@microsoft-github-policy-service agree company="Immanuel Tikhonov"