Skip to content

Introduce validations to Ci::RunnerNamespace and Ci::RunnerProject

Pedro Pombeiro requested to merge pedropombeiro/459996/validate-fields into master

What does this MR do and why?

note: I'd like to try getting the first 2 MRs in %17.1 if possible, as that will avoid us losing 1 milestone before we can tackle MR number 3.

This MR adds validations to Ci::RunnerNamespace and Ci::RunnerProject to ensure that no new records can be created with nil values. As mentioned in #459996 (closed), we have some old records with nil project_id. In order to introduce sharding keys in these tables, we'll need to be able to add a NOT NULL constraint. The first step towards doing that is to ensure no new invalid records can be created.

Step MR
1. Add validations so that new invalid records cannot be created !155756 (merged)
2. Remove invalid rows !155760 (merged), !155761 (merged)
3. Mark columns as NOT NULL MRs to come in %17.2

Part of #459996 (closed) and #446169 (closed)

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.

Before After
image image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Ci::RunnerNamespace.new(runner_id: Ci::Runner.group_type.last.id, namespace_id: nil).save!

should yield

ActiveRecord::RecordInvalid: Validation failed: Runner has already been taken, Namespace can't be blank
Edited by Pedro Pombeiro

Merge request reports