Skip to content

Commit 60c2ea2

Browse files
Codexclaude
andcommitted
fix: extract retry logic into function for BusyBox ash compatibility
BusyBox ash does not support the 'local' keyword outside of functions. The previous implementation used 'local pending_status' directly in the main loop, which caused ash to silently crash. Move the retry logic into a retry_pending_report() function defined before the main loop, where 'local' is valid. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 261dffe commit 60c2ea2

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

openwisp-config/files/openwisp.agent

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,19 @@ else
987987
env -i ACTION="restart" /sbin/hotplug-call openwisp
988988
fi
989989

990+
retry_pending_report() {
991+
local pending_status
992+
pending_status=$(cat "$PENDING_REPORT")
993+
logger "Retrying pending report_status: $pending_status" \
994+
-t openwisp \
995+
-p daemon.info
996+
retry_with_backoff report_status "$pending_status"
997+
# shellcheck disable=SC2181
998+
if [ "$?" -eq "0" ]; then
999+
rm -f "$PENDING_REPORT"
1000+
fi
1001+
}
1002+
9901003
while true; do
9911004
# check management interface at each iteration
9921005
# (because the address may change due to
@@ -1001,15 +1014,7 @@ while true; do
10011014
# Retry a previously failed report_status without re-downloading.
10021015
# This handles the case where the config was applied successfully
10031016
# but report_status failed due to a transient server error.
1004-
local pending_status
1005-
pending_status=$(cat "$PENDING_REPORT")
1006-
logger "Retrying pending report_status: $pending_status" \
1007-
-t openwisp \
1008-
-p daemon.info
1009-
retry_with_backoff report_status "$pending_status"
1010-
if [ "$?" -eq "0" ]; then
1011-
rm -f "$PENDING_REPORT"
1012-
fi
1017+
retry_pending_report
10131018
fi
10141019
env -i ACTION="end-of-cycle" /sbin/hotplug-call openwisp
10151020

0 commit comments

Comments
 (0)