Skip to content

Resolve "API Support for Immediate Group Deletion"

What does this MR do and why?

Currently, following is the behaviour of delete group API:

  • For non-EE users: The group gets immediately deleted when the user calls the API.
  • For EE users:
    • If the adjourned deletion is enabled then when the group delete API is called, groups and subgroups do not gets deleted immediately but gets queued for deletion and they get deleted after a certain duration(default 7 days). In this case, user can delete a group/subgroup immediately from UI but not from API.
    • If the adjourned deletion is not enabled then the groups and subgroups gets deleted immediately.

Proposed behaviour:

Refer #360008 (closed)

We need to support the option to immediately remove a subgroup via API:

  • Please add this feature behind a feature flag
  • Pass an optional parameter to DELETE /groups/:id, such as permanently_remove, that when set to true, will remove the subgroup immediately only if already previously marked for deletion
    • This parameter should be coupled with an additional, required parameter that accepts the subgroup's name (including its parent group(s), ex: parent-group/subgroup), similar to the confirmation that is required on the UI.
  • Request should fail if user authorized has a role lower than Owner
  • Only subgroups should be allowed to be permanently deleted with this feature. Top-level groups should continue to only be immediately deleted via the UI due to their significance, as they often represent an entire instance for our enterprise customers

Why?

#360008 (closed)

Implementation details

  • We will be making change in the existing delete groups API https://docs.gitlab.com/ee/api/groups.html#remove-group.
  • Only subgroups can be immediately deleted, not top level groups.
  • The subgroup needs to be marked for deletion first by calling the API being called presently.
  • Whoever is calling the API for deletion must have atleast Owner role.
  • We are adding two additional query parameters to be passed:
    • permanently_remove:
      • Type: Boolean
      • Purpose: For indicating that the subgroup will get permanently removed. Also the same param name is used for deleting the group immediately from UI.
    • full_path:
      • Type: String
      • Detail: This information for a subgroup can be fetched from any of the list groups APIs or detail API.
  • A feature flag named immediate_delete_subgroup_api is also being added, which will be enabled on group actor.
    • By default value is false.
    • Needs to enabled for each group.

How to set up and validate locally

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

  1. Checkout the branch 360008-api-support-for-immediate-group-deletion.
  2. Enable the feature flag on the desired group for which this needs to be tested by running following command in rails console.
    Feature.enable(:immediate_delete_subgroup_api, Group.find(<group_id>))
  3. Make sure there is atleast one subgroup of the above group.
  4. Firstly mark the subgroup to be deleted by running following command:
    curl --location --request DELETE 'localhost:3000/api/v4/groups/<subgroup_id>' \ --header 'PRIVATE-TOKEN: <token>'
  5. If you will check on UI or via API then you can see the subgroup has been marked for deletion.
  6. For immediately deleting the subgroup, call the following API:
    curl --location --request DELETE 'localhost:3000/api/v4/groups/<subgroup_id>?permanently_remove=true&full_path=<full_path_of_subgroup>' \ --header 'PRIVATE-TOKEN: <token>'
  7. If you will check the UI or API, the subgroup will be deleted immediately.

MR acceptance checklist

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

Related to #360008 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports

Loading