1
0
mirror of https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git synced 2026-06-21 00:07:16 +03:00

fix error when non-root user tries to cache latest endpoint, also don't need to re-cache same endpoint

This commit is contained in:
Jake Buchholz Göktürk 2026-06-15 16:26:44 -07:00
parent 6290b1e1bd
commit fbb910acc1
2 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,6 @@
# CHANGELOG
## 2026-06-XX - Tiny Cloud v3.3.3
## 2026-06-15 - Tiny Cloud v3.3.3
* Support IPv6 and multiple endpoints
[#68](https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud/-/work_items/68)
@ -9,6 +9,10 @@
routable. Fixes race condition between `dhcpcd` starting and attempting to
reach IMDS before routes are resolved.
* Currently the most recent IMDS endpoint that worked is cached, but only if
**root** is running `imds`. We may consider keeping track of this per user
in the future
## 2026-06-08 - Tiny Cloud v3.3.2
* Fixes an autodetect regression introduced in v3.3.1

View File

@ -120,7 +120,7 @@ _imds_has_route() {
}
_imds() {
local endpoint endpoints routed attempts=1
local endpoint endpoints routed attempts=1 cached
if [ "$IMDS_ENDPOINT_WAIT_ATTEMPTS" -le 0 ]; then
endpoints="$(_imds_endpoints)"
fi
@ -148,7 +148,8 @@ _imds() {
wget --quiet --timeout 1 --output-document - \
--header "$(_imds_header)" \
"http://$endpoint/$IMDS_URI/$1$IMDS_QUERY" && {
echo "$endpoint" > "$IMDS_ENDPOINT_CACHE"
cached="$(cat "$IMDS_ENDPOINT_CACHE" 2>/dev/null)" || :
[ "$endpoint" = "$cached" ] || echo "$endpoint" 2>/dev/null > "$IMDS_ENDPOINT_CACHE" || :
return 0
}
done