Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Removal of configurations was affected negatively by recent change #153

Closed
nemesifier opened this issue Nov 16, 2021 · 1 comment · Fixed by #154
Closed

[bug] Removal of configurations was affected negatively by recent change #153

nemesifier opened this issue Nov 16, 2021 · 1 comment · Fixed by #154
Assignees
Labels

Comments

@nemesifier
Copy link
Member

nemesifier commented Nov 16, 2021

After #144 has been merged I started to notice a new bug which took me some time to track down.

In short, when the new version of the agent is installed on devices which are already regsitered to OpenWISP, the code thinks that the very same configuration which is downloaded from OpenWISP is the original configuration to backup and later restore, with the result that trying to remove a configuration (eg: removing a template from the device) will not yield the desired result: the configuration is not removed (because it's restored by the new logic added in #144).

Here's how I can replicate this bug:

  1. ensure there's some templates added to the test openwisp instance and that a device is registered to the test instance and config is already applied
  2. remove /etc/openwisp/etc/ from openwrt
  3. restart the agent, then check /etc/openwisp/etc/, part of the config from openwisp may be stored there
  4. try removing a template from the device and save

Expected outcome: the configuration is removed
Actual outcome: the configuration is restored by the logic added to #144.

Proposed solution:

I believe the logic added in #144 should first check whether the piece of config it wants to store is coming from OpenWISP or not, to do that we can check whether the same configuration is present in the remote configuration (/etc/openwisp/remote/etc/config).

Then, while investigating on this bug I found out another aspect which can be improved.

The new logic creates a new dir in /etc/openwisp, eg: /etc/openwisp/etc/config/..., but we already have a directory which keeps a backup: /etc/openwisp/stored, it is used only to store plain files from the initial state (not UCI files), I wonder, was it intentional to not reuse this directory @okraits?

Unless there are issues, I would reuse this directory, so the original UCI files should be stored in /etc/openwisp/stored but only if not already present in /etc/openwisp/remote/ (because in that case the UCI config is coming from OpenWISP and should not be restored after it's removed).

@okraits
Copy link
Member

okraits commented Nov 26, 2021

Proposed solution:

I believe the logic added in #144 should first check whether the piece of config it wants to store is coming from OpenWISP or not, to do that we can check whether the same configuration is present in the remote configuration (/etc/openwisp/remote/etc/config).

We cannot solve this completely. We can check wether a specific section is coming from the controller (by looking at the config in the remote directory) but if it is coming from the controller then we don't know its previous state - wether it has been added or just modified by the controller, because there's no backup of the previous state. That is the original problem I wanted to solve with #76!

Then, while investigating on this bug I found out another aspect which can be improved.

The new logic creates a new dir in /etc/openwisp, eg: /etc/openwisp/etc/config/..., but we already have a directory which keeps a backup: /etc/openwisp/stored, it is used only to store plain files from the initial state (not UCI files), I wonder, was it intentional to not reuse this directory @okraits?

I did reuse this directory, that change probably was introduced by @devkapilbansal as stated in #154 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

3 participants