[bug] Device config status does not update to "modified" when organization variable is changed
Describe the bug Changing configuration variable in the Organization settings does not change the device's config status.
Steps To Reproduce
- Create a shared template:
- Name: WiFi
- Organization: Shared
- Type: Generic
- Backend: OpenWrt
- Default Values:
{ "ssid": "Shared" } - Config:
{ "interfaces": [ { "wireless": { "mode": "access_point", "radio": "radio0", "ssid": "{{ ssid }}" }, "type": "wireless", "name": "wlan0", "network": "br-lan" } ] }
- Create a device and apply this template to the device.
- Wait for the device's config status to change to "applied". You can also update it manually in the Django shell:
Config.objects.update(status='applied') - In the organization settings, add a configuration variable and save the organization setting.
{ "ssid": "OrgA" }
Expected behavior After adding the variable, the device's config status should change to "modified" and OpenWISP should try to push the configuration to the device.
Expected behavior After adding the variable, the device's config status should change to "modified" and OpenWISP should try to push the configuration to the device.
An important point, which we should replicate in the test case, is what happens if organization variables are changed and some devices of that organization are not affected? In this case, we should not change the status of those devices to modified.
One more question, does changing the status of a device automatically invalidate its checksum cache?
This sounds complex, we should probably execute this change in a celery task, or how do you think we should do this @pandafy?
We execute this task for invalidating the Config.checksum of the related devices
https://github.com/openwisp/openwisp-controller/blob/6ae8103d4b4eaf1c0d1f9e4dc2f6f93a3c6953f0/openwisp_controller/config/base/multitenancy.py#L65-L67
https://github.com/openwisp/openwisp-controller/blob/6ae8103d4b4eaf1c0d1f9e4dc2f6f93a3c6953f0/openwisp_controller/config/tasks.py#L154-L157
https://github.com/openwisp/openwisp-controller/blob/6ae8103d4b4eaf1c0d1f9e4dc2f6f93a3c6953f0/openwisp_controller/config/base/base.py#L49-L55
Currently, this task is not invalidating checksum of the controller views.
https://github.com/openwisp/openwisp-controller/blob/6b33d7304cf017c9623bfa6b101fe009b6f00acd/openwisp_controller/config/controller/views.py
I believe we need to handle #1113 first as it intersects with this.