Commit 34e35fa
[fix] Retry pending report_status instead of forcing re-download #251
When report_status fails after a configuration apply (e.g. due to a
transient HTTP 502 from the controller), the agent previously deleted
the local checksum files to trigger a full re-download on the next
cycle. That worked but wasted bandwidth and caused the controller to
stay stuck on "modified" until the next real config change.
Instead persist the unreported status in a pending_report marker file
and retry just report_status on the next polling cycle.
Key details:
- Define retry_pending_report as a shell function so "local" is valid
on BusyBox ash, where "local" outside a function is a parse error
that silently crashes the script mid-loop.
- Write the PENDING_REPORT marker atomically via a tmp file + rename so
a partial write (e.g. full disk) cannot leave a truncated marker
behind.
- Persist the marker BEFORE calling retry_with_backoff report_status so
a crash or reboot between the retry attempt and the PENDING_REPORT
write does not lose the status.
- Fall back to invalidating the persistent checksum when the pending
marker cannot be saved, preserving the previous force re-download
behaviour as a safety net.
- Validate the marker contents against the known-good status set
(applied/error) and discard a malformed marker rather than retrying
forever.
- Only retry a pending report after configuration_changed() returns 0
(confirmed no-change). Non-0/non-1 exit codes indicate checksum fetch
failures and the cached applied/error status may no longer reflect
the controller's current desired configuration.
- Only remove the marker after a successful report_status.
Closes #2511 parent 1f8beaa commit 34e35fa
2 files changed
Lines changed: 77 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
8 | 13 | | |
9 | 14 | | |
10 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
| |||
825 | 826 | | |
826 | 827 | | |
827 | 828 | | |
| 829 | + | |
828 | 830 | | |
829 | 831 | | |
830 | 832 | | |
| |||
833 | 835 | | |
834 | 836 | | |
835 | 837 | | |
836 | | - | |
| 838 | + | |
837 | 839 | | |
838 | | - | |
| 840 | + | |
839 | 841 | | |
840 | | - | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
841 | 860 | | |
842 | | - | |
843 | | - | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
844 | 873 | | |
845 | 874 | | |
846 | 875 | | |
| |||
977 | 1006 | | |
978 | 1007 | | |
979 | 1008 | | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
980 | 1038 | | |
981 | 1039 | | |
982 | 1040 | | |
983 | 1041 | | |
984 | 1042 | | |
985 | 1043 | | |
986 | 1044 | | |
| 1045 | + | |
987 | 1046 | | |
988 | | - | |
| 1047 | + | |
989 | 1048 | | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
990 | 1055 | | |
991 | 1056 | | |
992 | 1057 | | |
| |||
0 commit comments