Auto-delete projects of banned users after 60 days

What does this MR do and why?

Related to https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/702

This MR adds workers that automatically delete projects created and owned by banned users after a 60-day waiting period.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Enable the feature flag
    Feature.enable(:delete_banned_user_projects)
  2. Create a user.
  3. With the user create a project.
  4. Invite the user as an owner of a project the user did not create.
  5. Ban the user
  6. Monitor the sidekiq and application logs
    tail -f log/sidekiq.log | grep BannedUserProjectDeletion
    tail -f log/application_json.log | grep BannedUserProjectDeletion
  7. Trigger the AntiAbuse::BannedUserProjectDeletionCronWorker
    AntiAbuse::BannedUserProjectDeletionCronWorker.new.perform
  8. Nothing should have happened since the user has not been banned for 60 days. Update the created_at timestamp of the banned user and re-trigger the worker. You should now see logs emitted related to the project deletion and the project created by the banned user should be destroyed.
    Users::BannedUser.last.update!(created_at: 61.days.ago)
    AntiAbuse::BannedUserProjectDeletionCronWorker.new.perform
Edited by Ian Anderson

Merge request reports

Loading