mu300-update: a network error is tried again a few times (U30 Air test D5)

Right after boot the VPN is up a few seconds after mobile data (it is ordered after it); until then this network
passes nothing outside the tunnel, and "mu300-update check" said "could not reach GitHub". curl's --retry
leaves resets alone, so fetch_stdout tries a network error up to four times, 4 s apart; an HTTP error is not
retried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DqKKtBQZCfxYnHuBCuDqqn
This commit is contained in:
Abdurrahman Kaan DikeçandClaude Opus 5.5 committed 2026-10-05 03:04:14 +03:00
1 parent 44548ee90b
commit ddb3a12e91
2 files changed
+29 -2

No files matched your search

+13 -2
View File
@@ -30,9 +30,20 @@ have() { command -v "$1" >/dev/null 2>&1; }
# A transfer that stalls is cut off and retried rather than waited for: with older boot images the IPA's downlink
# can die in the middle of one (docs/FINDINGS.md 32), and without a timeout the update hung for good.
# A network error is tried again a few times (MU300_FETCH_DELAY s apart): right after boot the VPN comes up some
# seconds after mobile data, and a request in between is reset - "check" then said GitHub could not be reached.
# curl's own --retry leaves resets alone. An HTTP error (curl 22, a 404) is an answer and is not retried.
fetch_stdout() { # fetch_stdout URL
if have curl; then curl -fsSL --connect-timeout 30 --max-time 120 --retry 3 "$1"
else wget -T 60 -qO- "$1"; fi
_try=1
while :; do
if have curl; then _out=$(curl -fsSL --connect-timeout 30 --max-time 120 --retry 3 "$1"); _rc=$?
else _out=$(wget -T 60 -qO- "$1"); _rc=$?; fi
[ "$_rc" = 0 ] && { printf '%s\n' "$_out"; return 0; }
[ "$_rc" = 22 ] && have curl && return 1
[ "$_try" -ge 4 ] && return 1
_try=$((_try + 1))
sleep "${MU300_FETCH_DELAY:-4}"
done
}
fetch_file() { # fetch_file URL OUT (resumes a partial OUT)
if have curl; then curl -fL --retry 5 --retry-delay 5 --connect-timeout 30 --speed-limit 1024 --speed-time 60 -C - -o "$2" "$1"
+16
View File
@@ -30,6 +30,22 @@ class Update(ShellTest):
r = self.up(shell, 'echo loaded')
self.assertEqual((r.returncode, r.stdout), (0, 'loaded\n'), r.stderr)
def test_fetch_retries_a_network_error(self):
# right after boot the VPN is up some seconds after mobile data, and a request in between is reset
# (curl 35/56): "mu300-update check" then said "could not reach GitHub". Network errors are retried a few
# times; an HTTP error (22: 404 and the like) is an answer and is not.
for shell in self.each_shell():
for rc, fails, want_out, want_calls in ((56, 2, 'body', 3), (35, 1, 'body', 2), (22, 1, '', 1),
(7, 9, '', 4)):
n = self.tmp / 'n'
n.write_text('0')
self.stub('curl', f'c=$(($(cat "$STUBLOG/n") + 1)); echo $c > "$STUBLOG/n"; '
f'[ $c -gt {fails} ] && {{ echo body; exit 0; }}; exit {rc}')
r = self.up(shell, 'fetch_stdout https://example.invalid/x; echo "rc=$?"', MU300_FETCH_DELAY=0)
self.assertEqual(int(n.read_text()), want_calls, (rc, fails))
self.assertEqual(r.stdout.replace('rc=0\n', '').replace('rc=1\n', '').strip(), want_out, (rc, r.stdout))
self.assertIn('rc=0' if want_out else 'rc=1', r.stdout)
def test_rootfs_asset(self):
osr = self.disk / 'ubuntu' / 'etc' / 'os-release'
cases = [('24.04', {}, 'mu300-ubuntu-rootfs.tar.gz'),