Skip to content

[bug] NAS reboot path bypasses post_save signal for stale accounting sessions #734

Description

@pandafy

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:

  1. Create an active RADIUS accounting session.
  2. Trigger NAS reboot handling by sending an Accounting-On packet from the NAS.
  3. _close_stale_sessions_on_nas_boot updates the stale session(s) using .update() (sets stop_time and terminate_cause).
  4. No post_save signal is emitted and the monitoring task is not queued.
  5. 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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status
Done
Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions