openwisp / openwisp-config

OpenWRT configuration agent for OpenWISP Controller
https://openwisp.io/docs/dev/openwrt-config-agent/
GNU General Public License v3.0
372 stars 56 forks source link

[change] Log errors of openwisp-update-config in logd #168 #183

Closed pandafy closed 2 years ago

pandafy commented 2 years ago

Closes #168

github-actions[bot] commented 2 years ago

sh-checker report

To get the full details, please check in the job output.

shellcheck errors ``` 'shellcheck ' found no issues. ```
shfmt errors ``` 'shfmt ' returned error 1 finding the following formatting issues: ---------- --- openwisp_agent.orig +++ openwisp_agent @@ -718,7 +718,7 @@ REMOTE_CHECKSUM=$(tail -n 1 $CONFIGURATION_CHECKSUM 2>/dev/null) if [ "$LOCAL_CHECKSUM" != "$REMOTE_CHECKSUM" ]; then - logger -s "Configuration checksum mismatch! Local: $LOCAL_CHECKSUM, Remote: $REMOTE_CHECKSUM" \ + logger -s "Configuration checksum mismatch! Local: $LOCAL_CHECKSUM, Remote: $REMOTE_CHECKSUM" \ -t openwisp \ -p daemon.err # remove the checksum to ensure update is tried again at the next run ---------- You can reformat the above files to meet shfmt's requirements by typing: shfmt -w filename ```
pandafy commented 2 years ago

I have tested these two failing scenarios

root@pandafy-archer-c50:~# /etc/init.d/openwisp_config restart; logread -f
openwisp: OpenWISP config agent stopping
openwisp: OpenWISP config agent started
Tue Jul 12 12:40:04 2022 daemon.info openwisp: Local configuration outdated
Tue Jul 12 12:40:04 2022 daemon.info openwisp: Downloading configuration from controller...
Tue Jul 12 12:40:04 2022 daemon.info openwisp: Configuration downloaded, now applying it...
Tue Jul 12 12:40:04 2022 daemon.crit openwisp: Could not apply configuration, openwisp-update-config exit code was 1
Tue Jul 12 12:40:04 2022 daemon.crit openwisp: lua: /usr/sbin/openwisp-update-config:10: An error was encountered
Tue Jul 12 12:40:04 2022 daemon.crit openwisp: stack traceback:
Tue Jul 12 12:40:04 2022 daemon.crit openwisp:  [C]: in function 'error'
Tue Jul 12 12:40:04 2022 daemon.crit openwisp:  /usr/sbin/openwisp-update-config:10: in main chunk
Tue Jul 12 12:40:04 2022 daemon.crit openwisp:  [C]: ?
Tue Jul 12 12:40:10 2022 daemon.info openwisp: The most recent configuration backup was restored
root@pandafy-archer-c50:~# /etc/init.d/openwisp_config restart; logread -f
openwisp: OpenWISP config agent stopping
openwisp: OpenWISP config agent started
Tue Jul 12 12:40:38 2022 daemon.info openwisp: Local configuration outdated
Tue Jul 12 12:40:38 2022 daemon.info openwisp: Downloading configuration from controller...
Tue Jul 12 12:40:38 2022 daemon.info openwisp: Configuration downloaded, now applying it...
Tue Jul 12 12:40:38 2022 daemon.crit openwisp: Could not apply configuration, openwisp-update-config exit code was 1
Tue Jul 12 12:40:38 2022 daemon.crit openwisp: lua: /usr/sbin/openwisp-update-config:12: '=' expected near 'local'
Tue Jul 12 12:40:43 2022 daemon.info openwisp: The most recent configuration backup was restored

And ofcourse, the passing one

root@pandafy-archer-c50:~# /etc/init.d/openwisp_config restart; logread -f
openwisp: OpenWISP config agent stopping
openwisp: OpenWISP config agent started
Tue Jul 12 12:41:26 2022 daemon.info openwisp: Local configuration outdated
Tue Jul 12 12:41:26 2022 daemon.info openwisp: Downloading configuration from controller...
Tue Jul 12 12:41:26 2022 daemon.info openwisp: Configuration downloaded, now applying it...
Tue Jul 12 12:41:27 2022 daemon.info openwisp: Service openvpn has been reloaded via procd/ubus
Tue Jul 12 12:41:27 2022 daemon.info openwisp: Service system has been reloaded via procd/ubus
Tue Jul 12 12:41:31 2022 daemon.info dnsmasq[1652]: read /etc/hosts - 4 addresses
Tue Jul 12 12:41:31 2022 daemon.info dnsmasq[1652]: read /tmp/hosts/dhcp.dnsmasq1 - 2 addresses
Tue Jul 12 12:41:31 2022 daemon.info dnsmasq-dhcp[1652]: read /etc/ethers - 0 addresses
Tue Jul 12 09:41:32 2022 daemon.info openwisp: Testing configuration...
Tue Jul 12 09:41:32 2022 daemon.info openwisp: Configuration test succeeded
Tue Jul 12 09:41:32 2022 daemon.info openwisp: Configuration applied successfully
github-actions[bot] commented 2 years ago

sh-checker report

To get the full details, please check in the job output.

shellcheck errors ``` 'shellcheck ' found no issues. ```
shfmt errors ``` 'shfmt ' returned error 1 finding the following formatting issues: ---------- --- openwisp_agent.orig +++ openwisp_agent @@ -502,7 +502,7 @@ logger -s "Could not apply configuration, openwisp-update-config exit code was $exit_code" \ -t openwisp \ -p daemon.crit - logger -t openwisp -p daemon.crit -s < "$UPDATE_CONFIG_LOG" + logger -t openwisp -p daemon.crit -s <"$UPDATE_CONFIG_LOG" rm "$UPDATE_CONFIG_LOG" restore_backup return 1 ---------- You can reformat the above files to meet shfmt's requirements by typing: shfmt -w filename ```