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

Delete report format dirs last when deleting a user #1368

Merged
merged 8 commits into from
Dec 1, 2020

Conversation

mattmundell
Copy link
Contributor

@mattmundell mattmundell commented Nov 30, 2020

What:

When deleting a user, to avoid having to roll back the movement of the report format dirs, delete the dirs absolutely last. That is, delete dirs after all SQL has run, in case any of that SQL fails.

Why:

Errors in the SQL were leaving the report format dirs in an inconsistent state.

How did you test it:

  1. gvmd --create-user=webadmin --password=w --role=Admin
  2. as feed owner, delete 5 report formats, empty trashcan
  3. gvmd --modify-setting 78eceaec-3385-11ea-b237-28d24461215b --value UUID_OF_webadmin (set feed owner to webadmin)
  4. create table refs (id SERIAL PRIMARY KEY, owner integer REFERENCES users (id) ON DELETE RESTRICT);
  5. insert into refs (owner) values ((select id from users where name = 'webadmin'));
  6. ls var/lib/gvm/gvmd/report_formats/ => 5 files
  7. gvmd --delete-user=webadmin --inheritor=user2 (should fail due to refs)
  8. ls var/lib/gvm/gvmd/report_formats/ => still 5 files
  9. gvmd --delete-user=webadmin (should fail due to refs)
  10. ls var/lib/gvm/gvmd/report_formats/ => still 5 files
  11. delete from refs;
  12. repeat 7 or 9, should pass.

Checklist:

@mattmundell mattmundell marked this pull request as ready for review November 30, 2020 18:25
timopollmeier
timopollmeier previously approved these changes Dec 1, 2020
@timopollmeier timopollmeier merged commit bde96a6 into gvmd-20.08 Dec 1, 2020
@timopollmeier timopollmeier deleted the user-del-rollback branch October 15, 2021 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants