Skip to content

Add support for delayed project deletion for personal projects

What does this MR do and why?

  • This MR enables delayed project deletion feature for projects in user namespaces as well.
  • The deletion delay is same as that is set at the instance level. Users (user namespaces) cannot opt-out of delayed deletion if it's enabled at the instance level.
  • User namespaces on a GitLab Premium and above plan can use the pending deletion dashboard to restore their projects whereas GitLab Free users cannot restore the projects on their own, however, an instance admin can restore using the same dashboard.
  • Update the documentation to reflect that delayed deletion is also available in user namespaces i.e. for personal projects.

Screenshots or screen recordings

Project in free user namespace Project in paid user namespace
image image
image image

How to set up and validate locally

  1. Ensure that your GDK/local setup has ultimate license.
  2. Enable the check_namespace_plan via the application settings API so that even if the instance is on an ultimate plan, we can still create users without plans or free plans.
  3. Follow this doc so that your setup behaves as SaaS and therefore even if the instance is on an ultimate plan, we can still create users without plans or free plans OR Enable the check_namespace_plan via the application settings API so that even if the instance is on an ultimate plan, we can still create groups without plans.
  4. Enable delayed deletion feature at the instance level by navigating to Admin > Settings > General and enable "Default delayed project deletion" and set "Default deletion delay" to a value greater than 0.
  5. Create two users. Add the ultimate plan to one of these users from the admin panel (https://gdk.test:3000/admin/usesrs/user-name/edit). Make sure the other user is not on any plan or is on free/default plan.
  6. Make sure none of these users are admin users.
  7. Login with user1 belonging who is on free and create a private project.
    1. Navigate to the project settings and delete this project.
    2. The project should be deleted and the user should be navigated to the project dashboard page. A flash alert should be visible saying that the project will be deleted on 'YYYY-MM-DD' date.
    3. Go to the project's homepage and verify that 404 is thrown and the project is not visible.
    4. Navigate to the pending deletion dashboard and verify that the project that was deleted is not visible.
    5. This project should not be visible even via the projects API.
  8. Login with user2 who is on the paid plan and create a private project.
    1. Navigate to the project settings and delete this project.
    2. The project should be deleted and the user should be navigated to the project's homepage. A flash alert should be visible saying that the project will be deleted on 'YYYY-MM-DD' date.
    3. Navigate to the pending deletion dashboard. The project that was deleted is visible and the user also has an option to restore the project. The project will also be available via the /projects APIs.
  9. Login with an instance administrator and navigate to the pending deletion dashboard.
    1. Both the deleted projects should be visible and the instance admin has the option to restore any of these, even the project belonging to user1 who is on a free plan.
    2. Restore the project belonging to user1.
    3. Restore the project belonging to user2.
  10. Login with user1 again and verify that the project is now restored.
  11. Login with user2 again and verify that the project is now restored.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/364135

Merge request reports