From c9cd32f09398d7fb80aa752b35fbb4c6764f3a2d Mon Sep 17 00:00:00 2001 From: Daniyal Arshad Date: Wed, 23 Oct 2024 17:09:54 -0400 Subject: [PATCH] Finalize BackfillRootNamespaceClusterAgentMappings migration - Adds a postt migration to ensure background migration is finished - Updates finalized_by in background migration doc - Pins background migration spec to finalized schema version Changelog: changed --- ..._root_namespace_cluster_agent_mappings.yml | 2 +- ...l_root_namespace_cluster_agent_mappings.rb | 23 +++++++++++++++++++ db/schema_migrations/20241023210409 | 1 + ...t_namespace_cluster_agent_mappings_spec.rb | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 db/post_migrate/20241023210409_finalize_backfill_root_namespace_cluster_agent_mappings.rb create mode 100644 db/schema_migrations/20241023210409 diff --git a/db/docs/batched_background_migrations/backfill_root_namespace_cluster_agent_mappings.yml b/db/docs/batched_background_migrations/backfill_root_namespace_cluster_agent_mappings.yml index cbacdd74ba48a7..29551160222560 100644 --- a/db/docs/batched_background_migrations/backfill_root_namespace_cluster_agent_mappings.yml +++ b/db/docs/batched_background_migrations/backfill_root_namespace_cluster_agent_mappings.yml @@ -7,4 +7,4 @@ introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/159051 milestone: '17.2' queued_migration_version: 20240711035245 # Replace with the approximate date you think it's best to ensure the completion of this BBM. -finalized_by: # version of the migration that finalized this BBM +finalized_by: 20241023210409 diff --git a/db/post_migrate/20241023210409_finalize_backfill_root_namespace_cluster_agent_mappings.rb b/db/post_migrate/20241023210409_finalize_backfill_root_namespace_cluster_agent_mappings.rb new file mode 100644 index 00000000000000..453e31cc7c23ce --- /dev/null +++ b/db/post_migrate/20241023210409_finalize_backfill_root_namespace_cluster_agent_mappings.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class FinalizeBackfillRootNamespaceClusterAgentMappings < Gitlab::Database::Migration[2.2] + milestone '17.6' + MIGRATION = 'BackfillRootNamespaceClusterAgentMappings' + disable_ddl_transaction! + + restrict_gitlab_migration gitlab_schema: :gitlab_main_cell + + def up + ensure_batched_background_migration_is_finished( + job_class_name: MIGRATION, + table_name: :remote_development_agent_configs, + column_name: :id, + job_arguments: [], + finalize: true + ) + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20241023210409 b/db/schema_migrations/20241023210409 new file mode 100644 index 00000000000000..89be1ad38d1841 --- /dev/null +++ b/db/schema_migrations/20241023210409 @@ -0,0 +1 @@ +2f1567d2e69137fd8569367e58e61f0e4b81daa0baa131d2bbea3fbdc2f501eb \ No newline at end of file diff --git a/ee/spec/lib/ee/gitlab/background_migration/backfill_root_namespace_cluster_agent_mappings_spec.rb b/ee/spec/lib/ee/gitlab/background_migration/backfill_root_namespace_cluster_agent_mappings_spec.rb index 0cf715ccc009b0..d9f72d6cf1b3f6 100644 --- a/ee/spec/lib/ee/gitlab/background_migration/backfill_root_namespace_cluster_agent_mappings_spec.rb +++ b/ee/spec/lib/ee/gitlab/background_migration/backfill_root_namespace_cluster_agent_mappings_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe Gitlab::BackgroundMigration::BackfillRootNamespaceClusterAgentMappings, :migration, - feature_category: :workspaces do + schema: 20241023210409, feature_category: :workspaces do let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } let(:cluster_agents) { table(:cluster_agents) } -- GitLab