Clean up stale Security::PolicyProjectLink rows left by pre-18.1/18.3 transfers
Summary
#630855 fixes the root cause: projects transferred before GitLab 18.1 (projects) / 18.3 (groups) kept Security::PolicyProjectLink rows pointing at their old group's policies, so those policies kept enforcing (e.g. block_branch_modification blocked protected branch update/delete) with no supported way to clear it. The fix makes an INHERITED resyncSecurityPolicies reconcile the links going forward.
That fix doesn't touch existing stale rows. Anything created before the fix ships stays stale until someone runs a resync on the affected project. Two audiences need a way to do that.
Proposal
GitLab.com
One-off cleanup via a production change request, once the fix MR is deployed. For every project with a Security::PolicyProjectLink to a policy whose group-level configuration isn't in project.all_security_orchestration_policy_configurations(include_invalid: true), enqueue the reconcile as an admin user (the worker needs a user, and only uses it to remove the security policy bot when no configurations apply any more):
Security::Policies::GroupProjectTransferWorker.perform_async(project_id, admin_user_id)Select the affected projects in batches by project_id range. A single unbatched scan of all links takes several minutes on production-sized data.
Expect on the order of a thousand projects. Sample first against production data before enqueuing, to size the actual batch and confirm the selection query still matches after the fix ships.
Self-managed / Dedicated
No production access to run a one-off job, so add a troubleshooting entry to the security policies troubleshooting docs page telling admins/owners how to spot and fix an affected project:
- Symptoms: protected branch update/delete returns 403, the "Unprotect" action is disabled, and editing or unlinking the current policy project has no effect on the block.
- Fix: run the resync mutation on the affected project:
mutation { resyncSecurityPolicies(input: { fullPath: "<project path>", relationship: INHERITED }) { errors } }
Acceptance criteria
- Confirm the count of affected projects on GitLab.com via a read-only query before enqueuing anything.
- Production change request enqueues
Security::Policies::GroupProjectTransferWorker.perform_async(project_id, admin_user_id)for every affected project on GitLab.com. - Spot-check a handful of the affected projects after the change request runs: stale links are gone and protected branch update/delete works.
- Security policies troubleshooting docs page has a new entry covering the symptoms and the resync mutation fix for self-managed and Dedicated.