openwrt-openwisp-monitoring icon indicating copy to clipboard operation
openwrt-openwisp-monitoring copied to clipboard

[change] Stop sending data on repeated 404 responses #105

Open pandafy opened this issue 1 year ago • 2 comments
trafficstars

The openwisp-monitoring agent will exit (killing both the processes for collecting and sending data) if the device has been deleted from OpenWISP Controller.

The delete is determined by checking if the openwisp-config agent agent is running, which exits on repeated 404 response for checksum response.

Closes #105

pandafy avatar May 02 '24 13:05 pandafy

Pull Request Test Coverage Report for Build 8924705555

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 6 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.05%) to 99.768%

Files with Coverage Reduction New Missed Lines %
../files/lib/openwisp-monitoring/interfaces.lua 1 99.18%
test_dhcp.lua 1 98.11%
test_wifi.lua 2 98.54%
../files/sbin/netjson-monitoring.lua 2 98.54%
<!-- Total: 6
Totals Coverage Status
Change from base Build 7574230204: 0.05%
Covered Lines: 3013
Relevant Lines: 3020

💛 - Coveralls

coveralls avatar May 02 '24 13:05 coveralls

In my testing, I configured the openwisp-config agent to only retry once for re-spawning process and retry fetching checksum using the following settings

        option respawn_retry '1'
	option checksum_max_retries '1'

I did this to speed-up the time required for manual testing on the router.

I observed the logs after deleting the device from the controller, which are as follows

Thu May  2 13:01:30 2024 daemon.warn openwisp: Failed to retrieve checksum: 404 Not Found
Thu May  2 13:01:30 2024 daemon.err openwisp: Giving up and shutting down: the device may have been deleted from OpenWISP Controller
Thu May  2 13:01:35 2024 daemon.info openwisp-monitoring: OpenWISP monitoring daemon stopping
Thu May  2 13:01:35 2024 daemon.info openwisp-monitoring: OpenWISP monitoring daemon started
Thu May  2 13:01:36 2024 daemon.warn openwisp: Failed to retrieve checksum: 404 Not Found
Thu May  2 13:01:36 2024 daemon.err openwisp: Giving up and shutting down: the device may have been deleted from OpenWISP Controller
Thu May  2 13:01:36 2024 daemon.info procd: Instance openwisp_config::instance1 s in a crash loop 2 crashes, 2 seconds since last crash
Thu May  2 13:01:36 2024 daemon.err openwisp-monitoring: Giving up and shutting down: the device may have been deleted from OpenWISP Controller
Thu May  2 13:01:44 2024 daemon.err openwisp-monitoring: Giving up and shutting down: the device may have been deleted from OpenWISP Controller
Thu May  2 13:01:44 2024 daemon.info procd: Instance openwisp-monitoring::openwisp-monitoring_collect_data s in a crash loop 2 crashes, 2 seconds since last crash
Thu May  2 13:01:44 2024 daemon.info procd: Instance openwisp-monitoring::openwisp-monitoring_send_data s in a crash loop 2 crashes, 2 seconds since last crash

We can observe in the logs that openwisp-config agent exits twice (because of the configuration) and so does the collect and send processes of openwisp-monitoring agent.

pandafy avatar May 02 '24 13:05 pandafy