[go: up one dir, main page]

Add migration to create hosted runner records based on created by admin bot

What does this MR do and why?

This merge request introduces a migration specifically for GitLab Dedicated instances. It marks runners created by the admin bot as hosted runners. The migration only runs on Dedicated instances and not on .com or self-hosted setups. It finds the admin bot, then iterates through all runners created by this bot, marking each as a hosted runner. The migration is designed to be safe to re-run if it fails midway. A down migration is not implemented as it's unnecessary. The code also includes safeguards to allow cross-database modifications within a transaction, which is typically prevented.

Do not merge until https://gitlab.com/gitlab-com/gl-infra/gitlab-dedicated/instrumentor/-/merge_requests/5021 is merged.

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

NA

How to set up and validate locally

  1. Migration should be successful and if any records created by admin bot, should be created and associated with ci_hosted_runner table. Follow below steps for testing.
  2. Create some dummy runner records with -
Ci::Runner.create!(creator: Users::Internal.admin_bot, runner_type: 1)
  1. Check that Ci::HostedRunner table is empty by running Ci::HostedRunner.all
  2. Run the migration -
Gitlab::BackgroundMigration::MarkAdminBotRunnersAsHosted.new(start_id: Ci::Runner.minimum(:id), end_id: Ci::Runner.maximum(:id), batch_table: :ci_runners, batch_column: :id, pause_ms: 0, connection: ::Ci::ApplicationRecord.connection, sub_batch_size: 100).perform
  1. Check the HostedRunner table now with Ci::HostedRunner.all and you should see the records that you created in step 2.
Edited by Rajendra Kadam

Merge request reports

Loading