Allow destruction of records in archived pending_delete Projects
What does this MR do and why?
This change stops the prevent-create-update-destroy permission from applying to records within Projects that are pending_delete: true
. the purpose of the prevent
is to make "archived" projects reliably read-only, but this obviously shouldn't be the case if someone is deleting a project.
This hasn't been an issue before since we relied of FK constraints to remove the associated records after a Project is deleted. But with the FKs going away in the database decomposition effort, so too must our cascading destroys. Luckily we have very performant code to destroy records from ci_pipelines
, ci_builds
, and ci_job_artifacts
. We just need to allow that action to be taken in application logic permissions, where it will have to live going forward.
This use case recently caused a production issue requiring escalation to development: https://gitlab.com/gitlab-com/support/internal-requests/-/issues/10553
We tracked the problem down to this, and the spec introduced here successfully reproduces the issue.
Screenshots or screen recordings
Live debugging output in the internal support ticket: https://gitlab.com/gitlab-com/support/internal-requests/-/issues/10553#note_721539319
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Remove the new condition (
& ~pending_delete
) from the modified in rule in ProjectPolicy. - Run the added
'for an archived project'
context inprojects/destroy_service_spec.rb
and the updated'pipeline feature'
spec context inproject_policy_spec.rb
. - Observe spec failures.
- Add the
& ~pending_delete
back in. - Run the added
'for an archived project'
context inprojects/destroy_service_spec.rb
and the updated'pipeline feature'
spec context inproject_policy_spec.rb
. - Observe spec successes.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.