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

Store and restore original UCI configuration #76

Closed

Conversation

okraits
Copy link
Member

@okraits okraits commented Oct 15, 2018

I think this patch for #72 is finished now. I tested it in different situations with openwisp-controller.

@nemesisdesign Please review when you have the time.

I think it makes sense that somebody else writes a unittest so that the topic is thought through by two different people.

@okraits okraits force-pushed the tdt-restore-unmodified-config branch from 96a5ea8 to 95d62c7 Compare October 17, 2018 13:40
@okraits okraits changed the title WIP: Store and restore original UCI configuration Store and restore original UCI configuration Oct 17, 2018
@okraits okraits force-pushed the tdt-restore-unmodified-config branch from 95d62c7 to 5805a91 Compare October 18, 2018 12:07
@okraits
Copy link
Member Author

okraits commented Nov 21, 2018

@nemesisdesign How do you want to proceed with this one?

@nemesifier nemesifier added enhancement help wanted important Higher priority or release blocker labels Dec 6, 2018
@nemesifier nemesifier self-assigned this Dec 6, 2018
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okraits a basic test of this patch in the develop branch went well.

I cannot find time to write tests for this now and I am not sure who can do that, if you can't write tests for this we have to choose between leave the PR open until somebody can write the tests or merge without tests, both options are not optimal.

Do you think you can find the time to add a test for this case?

utils.remove_uci_options(standard, file, section)
else
-- section is in the backup configuration -> restore
-- delete all options first
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move these two lines of comments before the else for better readability

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I also moved the comment below the if above the if for consistency.

@okraits okraits force-pushed the tdt-restore-unmodified-config branch from 5805a91 to c2ea451 Compare January 11, 2019 05:45
@okraits
Copy link
Member Author

okraits commented Jan 11, 2019

@nemesisdesign I can write tests, I just need to find time to do it. Maybe I will have some time for it in the next weeks.

@okraits okraits force-pushed the tdt-restore-unmodified-config branch 2 times, most recently from f6628b1 to f2e4df8 Compare April 1, 2019 09:38
@nemesifier
Copy link
Member

@okraits did you send an update to this PR in the last 8 hours?

@okraits
Copy link
Member Author

okraits commented Apr 1, 2019

@okraits did you send an update to this PR in the last 8 hours?

Just a rebase to master. I started working on a unittest for this but it will take some time to get all cases covered.

@nemesifier
Copy link
Member

@okraits great!

Comment on lines +85 to +86
if not utils.starts_with_dot(option) then
standard:delete(file, section['.name'], option)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nemesisdesign @okraits
Here, if we are going to write the section, then what's the point of removing options before

Copy link
Member Author

@okraits okraits May 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact section from the backup configuration needs to be restored, so all existing options are removed so the restore can start from a clean state.

I think this is needed because utils.write_uci_section() doesn't remove a section before writing it: https://github.com/openwisp/openwisp-config/blob/master/openwisp-config/files/lib/openwisp/utils.lua#L66
We need to make sure that there are no old leftover options and that the section is restored as it was before openwisp-config modified it.

@devkapilbansal BTW great that you started to work on a test for this!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact section from the backup configuration needs to be restored, so all existing options are removed so the restore can start from a clean state.

Thanks for clearing this 😄
I wrote some tests for this here, a1e565b. I tried but wasn't to able update this pull request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okraits Can you please update this PR and check if tests are correct

I created a new branch on this repo 👇
https://github.com/openwisp/openwisp-config/tree/tdt-restore-unmodified-config

@devkapilbansal
Copy link
Member

Superseded by #144

@okraits okraits deleted the tdt-restore-unmodified-config branch November 18, 2021 10:51
@okraits okraits restored the tdt-restore-unmodified-config branch November 25, 2021 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted important Higher priority or release blocker
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[update-config] Create a backup of the local UCI configuration to be able to set it back to its original state
3 participants