Fix calculation of owner project when project runner is assigned
What does this MR do and why?
This MR fixes the calculation of owner project when a project runner is assigned. For context, before Cells 1.0 we used the ci_runner_projects
join record with the lowest id
value to determine the owner project. With Cells 1.0, there was the opportunity to use the sharding_key_id
column (which in the case of a project runner, contains the ID of the owner project) to avoid an extra SQL query. The problem is that the logic was slightly flawed, and this MR tries to address it in the following way:
- If the project referenced by
sharding_key_id
no longer exists, we try to determine the fallback project id (extracted this logic to a private method) - If there are no other candidate associated projects, we fallback to the new project being associated.
Changelog: fixed
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
n/a
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
The tests should cover all scenarios.