Improve validations for Ci::Runner#runner_type
See EE MR https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/5672
What does this MR do?
Right now we don't have the right validations to ensure the runner_type
is consistent with other attributes so we need to improve this.
It ensures that:
-
project
runner has at least one project, -
group
runner has exactly one group, -
is_shared
is consistent withrunner_type
, -
project
runner does not have groups, -
group
runner does not have projects, -
runner factory
by default definesinstance
runner, project/group runner has to be explicitly asked.
Are there points in the code the reviewer needs to double check?
Are these validations going to cause any serious performance problems? I think we save a runner every time contacted_at
changes and we are loading these relations every time. Seems problematic? Are there other such instances these validations will trigger since we assume that runners are saved infrequently otherwise.
Why was this MR needed?
Screenshots (if relevant)
Does this MR meet the acceptance criteria?
- [-] Changelog entry added, if necessary
- [-] Documentation created/updated
- [-] API support added
-
Tests added for this feature/bug - Review
- [-] Has been reviewed by UX
- [-] Has been reviewed by Frontend
-
Has been reviewed by Backend -
Has been reviewed by Database
-
Conform by the merge request performance guides -
Conform by the style guides -
Squashed related commits together - [-] Internationalization required/considered
-
End-to-end tests pass ( package-and-qa
manual pipeline job)
What are the relevant issue numbers?
Edited by Kamil Trzciński (Back 2025-01-01)