Background migration to copy projects.container_registry_enabled to project_features.container_registry_access_level [RUN ALL RSPEC]
What does this MR do?
Adds a background migration to copy projects.container_registry_enabled
to project_features.container_registry_access_level
:
- If
projects.container_registry_enabled
istrue
, setsproject_features.container_registry_access_level
to 20. - If
projects.container_registry_enabled
isfalse
, setsproject_features.container_registry_access_level
to 0. - If
projects.container_registry_enabled
isnull
, setsproject_features.container_registry_access_level
to 0.
This MR also:
- Adds a
before_update
callback to Project model, which copies any changes to theprojects.container_registry_enabled
column to theproject_features.container_registry_access_level
column. - Adds a
before_create
callback to theProjectFeature
model which sets the value of thecontainer_registry_access_level
based on the value ofprojects.container_registry_enabled
.
This is the 2nd in a series of MRs. Please see #18792 (comment 519028655) for more details:
Background migration estimates
projects table has 18,189,661 rows
All rows to be migrated.
50,000 rows per sidekiq job
18,189,661 / 50,000 = 364 jobs
1,000 rows per batch in job
50,000 / 1,000 = 50 batches per job
18,189,661 / 1,000 = 18,190 total batches
Estimated times per batch:
1466ms for update statement with 1000 items (from https://console.postgres.ai/gitlab/gitlab-production-tunnel/sessions/2565/commands/7900)
Execution time per sidekiq job:
1466 * 50 = 73.3 seconds
Sidekiq jobs are scheduled 2 minutes apart.
364 * 120 = 728 minutes = ~12.1 hours
Migration output
== 20210226120851 MoveContainerRegistryEnabledToProjectFeatures: migrating ====
-- Scheduled 1 MoveContainerRegistryEnabledToProjectFeature jobs with a maximum of 50000 records per batch and an interval of 120 seconds.
The migration is expected to take at least 120 seconds. Expect all jobs to have completed after 2021-03-08 19:24:33 UTC."
== 20210226120851 MoveContainerRegistryEnabledToProjectFeatures: migrated (0.1167s)
Revert migration output:
== 20210226120851 MoveContainerRegistryEnabledToProjectFeatures: reverting ====
== 20210226120851 MoveContainerRegistryEnabledToProjectFeatures: reverted (0.0000s)
Postgres.ai link for background migration update query
https://console.postgres.ai/gitlab/gitlab-production-tunnel/sessions/2565/commands/7900
Related to #18792 (closed)
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - Tested in all supported browsers
- Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- Label as security and @ mention
@gitlab-com/gl-security/appsec
- The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- Security reports checked/validated by a reviewer from the AppSec team