Describe the bug
When a NAS sends an Accounting-On packet, AbstractRadiusAccounting._close_stale_sessions_on_nas_boot closes stale sessions using a queryset .update():
https://github.com/openwisp/openwisp-radius/blob/HEAD/openwisp_radius/base/models.py#L586-L588
Django's .update() bypasses model save() and therefore does not emit post_save signals. The post_save_radiusaccounting receiver (connected in openwisp_radius/integrations/monitoring/apps.py:128) is not triggered, so tasks.post_save_radiusaccounting.delay() is never dispatched. As a result, accounting metrics for sessions closed during a NAS reboot are not recorded in openwisp-monitoring.
Suggested fix: iterate over affected sessions and call .save() on each, or dispatch the monitoring task explicitly after the bulk update.
Steps To Reproduce
Steps to reproduce the behavior:
- Create an active RADIUS accounting session.
- Trigger NAS reboot handling by sending an Accounting-On packet from the NAS.
_close_stale_sessions_on_nas_boot updates the stale session(s) using .update() (sets stop_time and terminate_cause).
- No
post_save signal is emitted and the monitoring task is not queued.
- Metrics for the closed session do not appear in openwisp-monitoring.
Expected behavior
When stale sessions are closed on NAS boot, the post_save_radiusaccounting task should be triggered so session metrics are recorded in openwisp-monitoring.
Describe the bug
When a NAS sends an Accounting-On packet,
AbstractRadiusAccounting._close_stale_sessions_on_nas_bootcloses stale sessions using a queryset.update():https://github.com/openwisp/openwisp-radius/blob/HEAD/openwisp_radius/base/models.py#L586-L588
Django's
.update()bypasses modelsave()and therefore does not emitpost_savesignals. Thepost_save_radiusaccountingreceiver (connected inopenwisp_radius/integrations/monitoring/apps.py:128) is not triggered, sotasks.post_save_radiusaccounting.delay()is never dispatched. As a result, accounting metrics for sessions closed during a NAS reboot are not recorded in openwisp-monitoring.Suggested fix: iterate over affected sessions and call
.save()on each, or dispatch the monitoring task explicitly after the bulk update.Steps To Reproduce
Steps to reproduce the behavior:
_close_stale_sessions_on_nas_bootupdates the stale session(s) using.update()(setsstop_timeandterminate_cause).post_savesignal is emitted and the monitoring task is not queued.Expected behavior
When stale sessions are closed on NAS boot, the
post_save_radiusaccountingtask should be triggered so session metrics are recorded in openwisp-monitoring.