openwisp-controller icon indicating copy to clipboard operation
openwisp-controller copied to clipboard

[bug] Device config status does not update to "modified" when organization variable is changed

Open pandafy opened this issue 6 months ago • 3 comments

Describe the bug Changing configuration variable in the Organization settings does not change the device's config status.

Steps To Reproduce

  1. 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"
              }
          ]
      }
      
  2. Create a device and apply this template to the device.
  3. 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')
    
  4. 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.

pandafy avatar Jun 20 '25 16:06 pandafy

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?

nemesifier avatar Jul 29 '25 17:07 nemesifier

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

pandafy avatar Jul 30 '25 08:07 pandafy

I believe we need to handle #1113 first as it intersects with this.

nemesifier avatar Sep 09 '25 21:09 nemesifier