Loading
Report bot transfer errors and add a flag to skip them
What does this MR do and why?
Moving group-owned bots during a group's organization transfer fails with a statement timeout for at least one group, which blocks that organization's activation. The error that reaches Sentry is a TransferError that carries only the PG message, so we can't tell which query timed out.
This MR makes two changes:
- Report the original error.
Organizations::Transfer::UsersServicereturns the original exception in its error payload, andGroupsService#transfer_bots_sliceraisesTransferErrorwith that exception as itscause.Gitlab::ErrorTrackingfollows the cause chain, so Sentry andexceptions_json.lognow record the SQL (exception.sql) and the original backtrace. - Put the bot transfer behind a flag.
GroupsServicenow moves group- and project-owned bots only whenorganization_transfer_group_bots(gitlab_com_derisk, off by default, root group actor) is enabled for the root group. This is not a "skip" flag: with the flag off, which is the default, bots are not transferred and stay in the source organization while the rest of the group moves. Enable the flag to transfer them. To move bots for a group that has already transferred, enable the flag and run a forced re-run (force: true).
References
- Introduced the inline bot transfer: 25733876 (Transfer group-owned bots with group organization)
Screenshots or screen recordings
Not applicable: no UI changes.
How to set up and validate locally
- In a Rails console, pick a top-level group that owns a service account or group access token bot, and an organization to move it to:
group = Group.find_by_full_path('<group-path>') - With the flag off (the default), transfer the group:
The group's descendants move, and its bots keep their original
Organizations::Transfer::GroupsService.new(group: group, new_organization: <org>, current_user: <admin>).executeorganization_id. - Enable the flag for the group and run a forced re-run:
The bots now move to the new organization.
Feature.enable(:organization_transfer_group_bots, group) Organizations::Transfer::GroupsService.new(group: group, new_organization: <org>, current_user: <admin>, force: true).execute
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Drew Blessing