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 deleted file mode 100644 index 295511602225603c9b8a5cc9efeb2f3d21dee5b7..0000000000000000000000000000000000000000 --- a/db/docs/batched_background_migrations/backfill_root_namespace_cluster_agent_mappings.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -migration_job_name: BackfillRootNamespaceClusterAgentMappings -description: Creates mappings between root namespaces and all cluster agents - within these namespaces that have remote development enabled -feature_category: remote_development -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: 20241023210409 diff --git a/db/docs/deleted_tables/remote_development_namespace_cluster_agent_mappings.yml b/db/docs/deleted_tables/remote_development_namespace_cluster_agent_mappings.yml new file mode 100644 index 0000000000000000000000000000000000000000..fcb2a5e200ba5d413646ff8772f992350d764a06 --- /dev/null +++ b/db/docs/deleted_tables/remote_development_namespace_cluster_agent_mappings.yml @@ -0,0 +1,15 @@ +--- +table_name: remote_development_namespace_cluster_agent_mappings +classes: + - RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping +feature_categories: + - workspaces +description: Moved to deleted because it got renamed to namespace_cluster_agent_mappings +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145101 +milestone: '16.10' +gitlab_schema: gitlab_main_cell +sharding_key: + namespace_id: namespaces +table_size: small +removed_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/181926 +removed_in_milestone: '17.10' diff --git a/db/docs/remote_development_namespace_cluster_agent_mappings.yml b/db/docs/namespace_cluster_agent_mappings.yml similarity index 62% rename from db/docs/remote_development_namespace_cluster_agent_mappings.yml rename to db/docs/namespace_cluster_agent_mappings.yml index 21a94c0092bcb59b4d9dc9e43bbe36876b83bbab..465929161c02fe9345cfddfa74337476bbb9402d 100644 --- a/db/docs/remote_development_namespace_cluster_agent_mappings.yml +++ b/db/docs/namespace_cluster_agent_mappings.yml @@ -1,14 +1,13 @@ --- -table_name: remote_development_namespace_cluster_agent_mappings +table_name: namespace_cluster_agent_mappings classes: -- RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping +- RemoteDevelopment::NamespaceClusterAgentMapping feature_categories: - workspaces description: This table records associations between Namespaces and Cluster Agents - as a part of supporting group-cluster agent association in the context of Remote - Development Workspaces -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145101 -milestone: '16.10' + as a part of supporting group-cluster agent association in the context of Workspaces +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/181926 +milestone: '17.10' gitlab_schema: gitlab_main_cell sharding_key: namespace_id: namespaces diff --git a/db/migrate/20250219055827_rename_remote_development_namespace_cluster_agent_mapping.rb b/db/migrate/20250219055827_rename_remote_development_namespace_cluster_agent_mapping.rb new file mode 100644 index 0000000000000000000000000000000000000000..4d99ae5374308092944cb84242ddf2da0aea5bbd --- /dev/null +++ b/db/migrate/20250219055827_rename_remote_development_namespace_cluster_agent_mapping.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class RenameRemoteDevelopmentNamespaceClusterAgentMapping < Gitlab::Database::Migration[2.2] + milestone '17.10' + + def up + rename_table_safely(:remote_development_namespace_cluster_agent_mappings, :namespace_cluster_agent_mappings) + end + + def down + undo_rename_table_safely(:remote_development_namespace_cluster_agent_mappings, :namespace_cluster_agent_mappings) + end +end diff --git a/db/post_migrate/20240711035245_queue_backfill_root_namespace_cluster_agent_mappings_again.rb b/db/post_migrate/20240711035245_queue_backfill_root_namespace_cluster_agent_mappings_again.rb deleted file mode 100644 index ec0c4cd76b0e4415572323e2e41893b8b2f82d92..0000000000000000000000000000000000000000 --- a/db/post_migrate/20240711035245_queue_backfill_root_namespace_cluster_agent_mappings_again.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class QueueBackfillRootNamespaceClusterAgentMappingsAgain < Gitlab::Database::Migration[2.2] - milestone '17.2' - - # Configure the `gitlab_schema` to perform data manipulation (DML). - # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html - restrict_gitlab_migration gitlab_schema: :gitlab_main_cell - MIGRATION = "BackfillRootNamespaceClusterAgentMappings" - DELAY_INTERVAL = 2.minutes - BATCH_SIZE = 1000 - SUB_BATCH_SIZE = 100 - - # Add dependent 'batched_background_migrations.queued_migration_version' values. - # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] - - def up - delete_batched_background_migration(MIGRATION, :remote_development_agent_configs, :id, []) - - queue_batched_background_migration( - MIGRATION, - :remote_development_agent_configs, - :id, - job_interval: DELAY_INTERVAL, - batch_size: BATCH_SIZE, - sub_batch_size: SUB_BATCH_SIZE - ) - end - - def down - delete_batched_background_migration(MIGRATION, :remote_development_agent_configs, :id, []) - end -end diff --git a/db/post_migrate/20250224063503_delete_remote_development_namespace_cluster_agent_mapping_view.rb b/db/post_migrate/20250224063503_delete_remote_development_namespace_cluster_agent_mapping_view.rb new file mode 100644 index 0000000000000000000000000000000000000000..16e31f84d20e282f5d6c6e3a340cdfe291b1e5e9 --- /dev/null +++ b/db/post_migrate/20250224063503_delete_remote_development_namespace_cluster_agent_mapping_view.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class DeleteRemoteDevelopmentNamespaceClusterAgentMappingView < Gitlab::Database::Migration[2.2] + milestone '17.10' + disable_ddl_transaction! + + def up + finalize_table_rename(:remote_development_namespace_cluster_agent_mappings, :namespace_cluster_agent_mappings) + end + + def down + undo_finalize_table_rename(:remote_development_namespace_cluster_agent_mappings, :namespace_cluster_agent_mappings) + end +end diff --git a/db/schema_migrations/20240711035245 b/db/schema_migrations/20240711035245 deleted file mode 100644 index e55810988579d7cafc64b172ab0f67d4923930ea..0000000000000000000000000000000000000000 --- a/db/schema_migrations/20240711035245 +++ /dev/null @@ -1 +0,0 @@ -5bd102fd3ff8463e40c4467317d3f146511ef683945e7c2cabaf8bff7abd3d04 \ No newline at end of file diff --git a/db/schema_migrations/20250219055827 b/db/schema_migrations/20250219055827 new file mode 100644 index 0000000000000000000000000000000000000000..388e56e855186972fbdefd3216d77d219bfe37e5 --- /dev/null +++ b/db/schema_migrations/20250219055827 @@ -0,0 +1 @@ +166459c440ed6e868c66ddc3b79a5aae27b20d2bc21e489123b6676f8cd97841 \ No newline at end of file diff --git a/db/schema_migrations/20250224063503 b/db/schema_migrations/20250224063503 new file mode 100644 index 0000000000000000000000000000000000000000..85f846fcfe0997d9a351a0084cb359d98708a4d5 --- /dev/null +++ b/db/schema_migrations/20250224063503 @@ -0,0 +1 @@ +dbdfbe9e0140762dcb606ee83ee5ac6ee6f2f0c4b9a60979f73394a9f81ec2e6 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 56db66feda0a281012b24d76723396f36cbd2dbe..43638c89eb53b5f56c4ca15a614b857f90869a2a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -16895,6 +16895,24 @@ CREATE TABLE namespace_ci_cd_settings ( allow_stale_runner_pruning boolean DEFAULT false NOT NULL ); +CREATE TABLE namespace_cluster_agent_mappings ( + id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + namespace_id bigint NOT NULL, + cluster_agent_id bigint NOT NULL, + creator_id bigint +); + +CREATE SEQUENCE namespace_cluster_agent_mappings_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE namespace_cluster_agent_mappings_id_seq OWNED BY namespace_cluster_agent_mappings.id; + CREATE TABLE namespace_commit_emails ( id bigint NOT NULL, user_id bigint NOT NULL, @@ -20725,24 +20743,6 @@ CREATE SEQUENCE releases_id_seq ALTER SEQUENCE releases_id_seq OWNED BY releases.id; -CREATE TABLE remote_development_namespace_cluster_agent_mappings ( - id bigint NOT NULL, - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, - namespace_id bigint NOT NULL, - cluster_agent_id bigint NOT NULL, - creator_id bigint -); - -CREATE SEQUENCE remote_development_namespace_cluster_agent_mappings_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE remote_development_namespace_cluster_agent_mappings_id_seq OWNED BY remote_development_namespace_cluster_agent_mappings.id; - CREATE TABLE remote_mirrors ( id bigint NOT NULL, project_id bigint, @@ -25868,6 +25868,8 @@ ALTER TABLE ONLY namespace_admin_notes ALTER COLUMN id SET DEFAULT nextval('name ALTER TABLE ONLY namespace_bans ALTER COLUMN id SET DEFAULT nextval('namespace_bans_id_seq'::regclass); +ALTER TABLE ONLY namespace_cluster_agent_mappings ALTER COLUMN id SET DEFAULT nextval('namespace_cluster_agent_mappings_id_seq'::regclass); + ALTER TABLE ONLY namespace_commit_emails ALTER COLUMN id SET DEFAULT nextval('namespace_commit_emails_id_seq'::regclass); ALTER TABLE ONLY namespace_import_users ALTER COLUMN id SET DEFAULT nextval('namespace_import_users_id_seq'::regclass); @@ -26144,8 +26146,6 @@ ALTER TABLE ONLY release_links ALTER COLUMN id SET DEFAULT nextval('release_link ALTER TABLE ONLY releases ALTER COLUMN id SET DEFAULT nextval('releases_id_seq'::regclass); -ALTER TABLE ONLY remote_development_namespace_cluster_agent_mappings ALTER COLUMN id SET DEFAULT nextval('remote_development_namespace_cluster_agent_mappings_id_seq'::regclass); - ALTER TABLE ONLY remote_mirrors ALTER COLUMN id SET DEFAULT nextval('remote_mirrors_id_seq'::regclass); ALTER TABLE ONLY required_code_owners_sections ALTER COLUMN id SET DEFAULT nextval('required_code_owners_sections_id_seq'::regclass); @@ -28447,6 +28447,9 @@ ALTER TABLE ONLY namespace_bans ALTER TABLE ONLY namespace_ci_cd_settings ADD CONSTRAINT namespace_ci_cd_settings_pkey PRIMARY KEY (namespace_id); +ALTER TABLE ONLY namespace_cluster_agent_mappings + ADD CONSTRAINT namespace_cluster_agent_mappings_pkey PRIMARY KEY (id); + ALTER TABLE ONLY namespace_commit_emails ADD CONSTRAINT namespace_commit_emails_pkey PRIMARY KEY (id); @@ -28996,9 +28999,6 @@ ALTER TABLE releases ALTER TABLE ONLY releases ADD CONSTRAINT releases_pkey PRIMARY KEY (id); -ALTER TABLE ONLY remote_development_namespace_cluster_agent_mappings - ADD CONSTRAINT remote_development_namespace_cluster_agent_mappings_pkey PRIMARY KEY (id); - ALTER TABLE ONLY remote_mirrors ADD CONSTRAINT remote_mirrors_pkey PRIMARY KEY (id); @@ -31072,9 +31072,9 @@ CREATE UNIQUE INDEX i_duo_workflows_events_on_correlation_id ON duo_workflows_ev CREATE INDEX i_gitlab_subscription_histories_on_namespace_change_type_plan ON gitlab_subscription_histories USING btree (namespace_id, change_type, hosted_plan_id); -CREATE INDEX i_namespace_cluster_agent_mappings_on_cluster_agent_id ON remote_development_namespace_cluster_agent_mappings USING btree (cluster_agent_id); +CREATE INDEX i_namespace_cluster_agent_mappings_on_cluster_agent_id ON namespace_cluster_agent_mappings USING btree (cluster_agent_id); -CREATE INDEX i_namespace_cluster_agent_mappings_on_creator_id ON remote_development_namespace_cluster_agent_mappings USING btree (creator_id); +CREATE INDEX i_namespace_cluster_agent_mappings_on_creator_id ON namespace_cluster_agent_mappings USING btree (creator_id); CREATE INDEX i_organization_cluster_agent_mappings_on_creator_id ON organization_cluster_agent_mappings USING btree (creator_id); @@ -36412,7 +36412,7 @@ CREATE UNIQUE INDEX unique_merge_request_metrics_by_merge_request_id ON merge_re CREATE INDEX unique_ml_model_versions_on_model_id_and_id ON ml_model_versions USING btree (model_id, id DESC); -CREATE UNIQUE INDEX unique_namespace_cluster_agent_mappings_for_agent_association ON remote_development_namespace_cluster_agent_mappings USING btree (namespace_id, cluster_agent_id); +CREATE UNIQUE INDEX unique_namespace_cluster_agent_mappings_for_agent_association ON namespace_cluster_agent_mappings USING btree (namespace_id, cluster_agent_id); CREATE UNIQUE INDEX unique_organizations_on_path_case_insensitive ON organizations USING btree (lower(path)); @@ -38985,7 +38985,7 @@ ALTER TABLE ONLY audit_events_amazon_s3_configurations ALTER TABLE ONLY issue_customer_relations_contacts ADD CONSTRAINT fk_0c0037f723 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE; -ALTER TABLE ONLY remote_development_namespace_cluster_agent_mappings +ALTER TABLE ONLY namespace_cluster_agent_mappings ADD CONSTRAINT fk_0c483ecb9d FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; ALTER TABLE ONLY zoekt_replicas @@ -39036,7 +39036,7 @@ ALTER TABLE ONLY protected_environment_deploy_access_levels ALTER TABLE ONLY cluster_agent_migrations ADD CONSTRAINT fk_1211a345fb FOREIGN KEY (agent_id) REFERENCES cluster_agents(id) ON DELETE CASCADE; -ALTER TABLE ONLY remote_development_namespace_cluster_agent_mappings +ALTER TABLE ONLY namespace_cluster_agent_mappings ADD CONSTRAINT fk_124d8167c5 FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE SET NULL; ALTER TABLE ONLY cluster_agent_url_configurations @@ -40401,7 +40401,7 @@ ALTER TABLE ONLY ci_sources_pipelines ALTER TABLE ONLY packages_maven_metadata ADD CONSTRAINT fk_be88aed360 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE CASCADE; -ALTER TABLE ONLY remote_development_namespace_cluster_agent_mappings +ALTER TABLE ONLY namespace_cluster_agent_mappings ADD CONSTRAINT fk_be8e9c740f FOREIGN KEY (cluster_agent_id) REFERENCES cluster_agents(id) ON DELETE CASCADE; ALTER TABLE ONLY oauth_device_grants diff --git a/ee/app/finders/remote_development/cluster_agents_finder.rb b/ee/app/finders/remote_development/cluster_agents_finder.rb index 892ad043265d3d771cef6e272c5a94cdcb7eec70..68bf128175f16fe9ed5b676c13610cd9310de3df 100644 --- a/ee/app/finders/remote_development/cluster_agents_finder.rb +++ b/ee/app/finders/remote_development/cluster_agents_finder.rb @@ -15,7 +15,7 @@ def self.fetch_agents(filter, namespace, user) # noinspection RailsParamDefResolve -- A symbol is a valid argument for 'select' existing_mapped_agents = - RemoteDevelopmentNamespaceClusterAgentMapping + NamespaceClusterAgentMapping .for_namespaces([namespace.id]) .select(:cluster_agent_id) @@ -28,7 +28,7 @@ def self.fetch_agents(filter, namespace, user) when :directly_mapped return Clusters::Agent.none unless user_can_read_namespace_agent_mappings?(user: user, namespace: namespace) - relevant_mappings = RemoteDevelopmentNamespaceClusterAgentMapping.for_namespaces([namespace.id]) + relevant_mappings = NamespaceClusterAgentMapping.for_namespaces([namespace.id]) relevant_mappings = NamespaceClusterAgentMappingOperations::Validations.filter_valid_namespace_cluster_agent_mappings( namespace_cluster_agent_mappings: relevant_mappings.to_a @@ -36,7 +36,7 @@ def self.fetch_agents(filter, namespace, user) Clusters::Agent.id_in(relevant_mappings.map(&:cluster_agent_id)) when :available - relevant_mappings = RemoteDevelopmentNamespaceClusterAgentMapping.for_namespaces(namespace.traversal_ids) + relevant_mappings = NamespaceClusterAgentMapping.for_namespaces(namespace.traversal_ids) relevant_mappings = NamespaceClusterAgentMappingOperations::Validations.filter_valid_namespace_cluster_agent_mappings( namespace_cluster_agent_mappings: relevant_mappings.to_a diff --git a/ee/app/graphql/mutations/remote_development/workspace_operations/create.rb b/ee/app/graphql/mutations/remote_development/workspace_operations/create.rb index d9b92d0f0a2df4d78ab41b86c90cffec47ad5333..366f7c9760c375e7d44ed2fb241b9070fc913466 100644 --- a/ee/app/graphql/mutations/remote_development/workspace_operations/create.rb +++ b/ee/app/graphql/mutations/remote_development/workspace_operations/create.rb @@ -100,7 +100,7 @@ def resolve(args) # noinspection RubyNilAnalysis - RubyMine thinks project or agent may be nil, but this is not possible # because authorized_find! would have thrown an exception. relevant_mappings = - ::RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping + ::RemoteDevelopment::NamespaceClusterAgentMapping .for_namespaces(project.project_namespace.traversal_ids) .for_agents([agent.id]) diff --git a/ee/app/models/ee/clusters/agent.rb b/ee/app/models/ee/clusters/agent.rb index 9ca0028e314170dd1deb333ca269a8d05506f2db..3cf72dfeed2324b5676c45ffad9687e3d619fa7b 100644 --- a/ee/app/models/ee/clusters/agent.rb +++ b/ee/app/models/ee/clusters/agent.rb @@ -36,8 +36,8 @@ module Agent inverse_of: :agent, foreign_key: :cluster_agent_id - has_many :remote_development_namespace_cluster_agent_mappings, - class_name: 'RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping', + has_many :namespace_cluster_agent_mappings, + class_name: 'RemoteDevelopment::NamespaceClusterAgentMapping', inverse_of: :agent, foreign_key: 'cluster_agent_id' diff --git a/ee/app/models/ee/namespace.rb b/ee/app/models/ee/namespace.rb index 2cceb9e85f4e25d32623a933c8605fda21922ea4..fee2874a8047ea9505981c98665449aed8e6246d 100644 --- a/ee/app/models/ee/namespace.rb +++ b/ee/app/models/ee/namespace.rb @@ -66,8 +66,8 @@ module Namespace has_one :zoekt_enabled_namespace, class_name: '::Search::Zoekt::EnabledNamespace', foreign_key: :root_namespace_id, inverse_of: :namespace - has_many :remote_development_namespace_cluster_agent_mappings, - class_name: 'RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping', + has_many :namespace_cluster_agent_mappings, + class_name: 'RemoteDevelopment::NamespaceClusterAgentMapping', foreign_key: 'namespace_id', inverse_of: :namespace has_many :hosted_runner_monthly_usages, diff --git a/ee/app/models/ee/user.rb b/ee/app/models/ee/user.rb index 4fe9f54c035dec4aba1d580c81c0c831e048ea91..3642dd4a495e5d44b5870c2a865b5e5368444535 100644 --- a/ee/app/models/ee/user.rb +++ b/ee/app/models/ee/user.rb @@ -133,8 +133,8 @@ module User has_many :assigned_add_ons, class_name: 'GitlabSubscriptions::UserAddOnAssignment', inverse_of: :user, dependent: :destroy # rubocop:enable Cop/ActiveRecordDependent -- legacy usage - has_many :created_remote_development_namespace_cluster_agent_mappings, - class_name: 'RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping', + has_many :created_namespace_cluster_agent_mappings, + class_name: 'RemoteDevelopment::NamespaceClusterAgentMapping', inverse_of: :user has_many :created_organization_cluster_agent_mappings, diff --git a/ee/app/models/remote_development/remote_development_namespace_cluster_agent_mapping.rb b/ee/app/models/remote_development/namespace_cluster_agent_mapping.rb similarity index 62% rename from ee/app/models/remote_development/remote_development_namespace_cluster_agent_mapping.rb rename to ee/app/models/remote_development/namespace_cluster_agent_mapping.rb index 6aab09435497541eaa5078d79184dd65911aed1e..1e0df8140c7ead7816bd603c24ef6bb588a1475c 100644 --- a/ee/app/models/remote_development/remote_development_namespace_cluster_agent_mapping.rb +++ b/ee/app/models/remote_development/namespace_cluster_agent_mapping.rb @@ -1,16 +1,17 @@ # frozen_string_literal: true module RemoteDevelopment - class RemoteDevelopmentNamespaceClusterAgentMapping < ApplicationRecord - belongs_to :namespace, inverse_of: :remote_development_namespace_cluster_agent_mappings + # model + class NamespaceClusterAgentMapping < ApplicationRecord + belongs_to :namespace, inverse_of: :namespace_cluster_agent_mappings belongs_to :user, class_name: 'User', foreign_key: 'creator_id', - inverse_of: :created_remote_development_namespace_cluster_agent_mappings + inverse_of: :created_namespace_cluster_agent_mappings belongs_to :agent, class_name: 'Clusters::Agent', foreign_key: 'cluster_agent_id', - inverse_of: :remote_development_namespace_cluster_agent_mappings + inverse_of: :namespace_cluster_agent_mappings validates :namespace, presence: true validates :agent, presence: true diff --git a/ee/lib/ee/gitlab/background_migration/backfill_root_namespace_cluster_agent_mappings.rb b/ee/lib/ee/gitlab/background_migration/backfill_root_namespace_cluster_agent_mappings.rb deleted file mode 100644 index a5aa644e3d8ccf278c799b0bc028902f93ea9755..0000000000000000000000000000000000000000 --- a/ee/lib/ee/gitlab/background_migration/backfill_root_namespace_cluster_agent_mappings.rb +++ /dev/null @@ -1,150 +0,0 @@ -# frozen_string_literal: true - -# See https://docs.gitlab.com/ee/development/database/batched_background_migrations.html -# for more information on how to use batched background migrations - -# Update below commented lines with appropriate values. - -module EE - module Gitlab - module BackgroundMigration - module BackfillRootNamespaceClusterAgentMappings - extend ActiveSupport::Concern - extend ::Gitlab::Utils::Override - - prepended do - operation_name :backfill_root_namespace_cluster_agent_mappings - scope_to ->(relation) { relation.where(enabled: true) } - end - - module LogUtils - MIGRATOR = 'BackfillRootNamespaceClusterAgentMappings' - - def log_info(log_attributes) - ::Gitlab::BackgroundMigration::Logger.info(log_attributes.merge(migrator: MIGRATOR)) - end - end - - class Project < ::ApplicationRecord - self.table_name = 'projects' - end - - class Namespace < ::ApplicationRecord - self.table_name = 'namespaces' - self.inheritance_column = :_type_disabled - end - - class ClusterAgent < ::ApplicationRecord - self.table_name = 'cluster_agents' - end - - class RemoteDevelopmentNamespaceClusterAgentMapping < ::ApplicationRecord - extend LogUtils - - self.table_name = 'remote_development_namespace_cluster_agent_mappings' - - INSERT_SQL = <<~SQL.squish - INSERT INTO remote_development_namespace_cluster_agent_mappings - (namespace_id, cluster_agent_id, creator_id, created_at, updated_at) - VALUES - %{insert_tuples} - ON CONFLICT (namespace_id, cluster_agent_id) DO NOTHING; - SQL - class << self - def insert_namespace_cluster_agent_mappings(mappings) - return log_info(message: 'No mappings to create') unless mappings.present? - - tuples = mappings.map do |mapping| - format( - "(%{namespace_id}, %{cluster_agent_id}, %{creator_id}, NOW(), NOW())", - namespace_id: mapping[:namespace_id], - cluster_agent_id: mapping[:cluster_agent_id], - creator_id: migration_user.id - ) - end - - run_insert(tuples) - end - - private - - def run_insert(tuples) - insert_sql = format(INSERT_SQL, insert_tuples: tuples.join(', ')) - - connection.execute(insert_sql) - log_info(message: 'Insert query has been executed') - end - - def migration_user - ::Users::Internal.migration_bot - end - end - end - - include LogUtils - - override :perform - def perform - each_sub_batch do |sub_batch| - ids = sub_batch.map(&:id) - log_info(message: 'Migration started for batch', start_id: ids.min, end_id: ids.max) - - relevant_agent_ids = sub_batch.map(&:cluster_agent_id) - root_group_by_agent_id = root_groups_for_cluster_agents(cluster_agent_ids: relevant_agent_ids) - - mappings = root_group_by_agent_id.map do |cluster_agent_id, root_group_id| - { - namespace_id: root_group_id, - cluster_agent_id: cluster_agent_id - } - end - - RemoteDevelopmentNamespaceClusterAgentMapping.insert_namespace_cluster_agent_mappings(mappings) - log_info(message: 'Migration ended for batch', start_id: ids.min, end_id: ids.max) - end - end - - # rubocop:disable Metrics/AbcSize -- Disabled temporarily to roll out a time critical bugfix - def root_groups_for_cluster_agents(cluster_agent_ids:) - agents_by_id = ClusterAgent.id_in(cluster_agent_ids).index_by(&:id) - - projects_by_id = Project.id_in(agents_by_id.values.map(&:project_id)).index_by(&:id) - - project_namespaces_by_id = - Namespace.id_in(projects_by_id.values.map(&:project_namespace_id)).index_by(&:id) - - root_namespace_ids = project_namespaces_by_id.values.map do |project_namespace| - project_namespace.traversal_ids[0] - end - - root_group_namespaces_by_id = - Namespace - .id_in(root_namespace_ids) - .where(type: 'Group') - .index_by(&:id) - - cluster_agent_ids.each_with_object({}) do |cluster_agent_id, hash| - next unless agents_by_id.has_key?(cluster_agent_id) - - agent = agents_by_id[cluster_agent_id] - - # projects_by_id must contain agent.project_id as "agents" table has a ON CASCADE DELETE constraint with - # respect to the "projects" table. As such, if an agent can be retrieved from the database, - # so should its project - project = projects_by_id[agent.project_id] - - # project_namespaces_by_id must contain project.project_namespace_id as "projects" table has a - # ON CASCADE DELETE constraint with respect to the projects table. As such, if a project can be retrieved - # from the database, so should its project_namespace - project_namespace = project_namespaces_by_id[project.project_namespace_id] - - root_namespace_id = project_namespace.traversal_ids.first - - hash[cluster_agent_id] = root_namespace_id if root_group_namespaces_by_id.has_key?(root_namespace_id) - end - end - # rubocop:enable Metrics/AbcSize - end - end - end -end diff --git a/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/create/mapping_creator.rb b/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/create/mapping_creator.rb index dd0b9f8b2480209814797f64a79c34ae62d4d4f7..aa4cac8790d8ce04345b8c80a319aaa14802e9ab 100644 --- a/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/create/mapping_creator.rb +++ b/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/create/mapping_creator.rb @@ -15,7 +15,7 @@ def self.create(context) user: User => user } - new_mapping = RemoteDevelopmentNamespaceClusterAgentMapping.new( + new_mapping = NamespaceClusterAgentMapping.new( cluster_agent_id: cluster_agent.id, namespace_id: namespace.id, creator_id: user.id diff --git a/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/mapping_deleter.rb b/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/mapping_deleter.rb index 1055a46c0f94e112bda04220b30e72ecfc974269..cd82387d0d47e4424709935027e46324af51b03e 100644 --- a/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/mapping_deleter.rb +++ b/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/mapping_deleter.rb @@ -14,7 +14,7 @@ def self.delete(context) cluster_agent: Clusters::Agent => cluster_agent } - delete_count = RemoteDevelopmentNamespaceClusterAgentMapping.delete_by( + delete_count = NamespaceClusterAgentMapping.delete_by( namespace_id: namespace.id, cluster_agent_id: cluster_agent.id ) diff --git a/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/validations.rb b/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/validations.rb index 96fd63f4c99d690ce01d0c1bb050e2dc365f64e0..27509ad3de318cdb3840d6ffa26ad4b2dd40bb4e 100644 --- a/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/validations.rb +++ b/ee/lib/remote_development/namespace_cluster_agent_mapping_operations/validations.rb @@ -7,8 +7,8 @@ class Validations # agents are excluded from the response. A cluster agent is said to reside within a namespace # if the namespace id is present in the traversal ids of the project bound to the cluster agent # - # @param [Array] namespace_cluster_agent_mappings - # @return [Array] + # @param [Array] namespace_cluster_agent_mappings + # @return [Array] def self.filter_valid_namespace_cluster_agent_mappings(namespace_cluster_agent_mappings:) agent_ids = namespace_cluster_agent_mappings.map(&:cluster_agent_id) traversal_ids_for_agents = traversal_ids_for_cluster_agents(cluster_agent_ids: agent_ids) diff --git a/ee/spec/factories/remote_development/remote_development_namespace_cluster_agent_mappings.rb b/ee/spec/factories/remote_development/remote_development_namespace_cluster_agent_mappings.rb index 5bd5853dff2f5eeb3d1e02e26e2f4310812ffd8e..74f74220da78367672795ece1e4e3aab4015bf44 100644 --- a/ee/spec/factories/remote_development/remote_development_namespace_cluster_agent_mappings.rb +++ b/ee/spec/factories/remote_development/remote_development_namespace_cluster_agent_mappings.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :remote_development_namespace_cluster_agent_mapping, - class: 'RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping' do + class: 'RemoteDevelopment::NamespaceClusterAgentMapping' do user agent factory: [:cluster_agent, :in_group] namespace { agent.project.namespace } 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 deleted file mode 100644 index d06229feec1fd9f37a7c0f9011e81d692d53aa7b..0000000000000000000000000000000000000000 --- a/ee/spec/lib/ee/gitlab/background_migration/backfill_root_namespace_cluster_agent_mappings_spec.rb +++ /dev/null @@ -1,210 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Gitlab::BackgroundMigration::BackfillRootNamespaceClusterAgentMappings, :migration, - schema: 20241023210409, feature_category: :workspaces do - let(:organizations) { table(:organizations) } - let(:namespaces) { table(:namespaces) } - let(:projects) { table(:projects) } - let(:cluster_agents) { table(:cluster_agents) } - let(:rd_agent_configs) { table(:remote_development_agent_configs) } - let(:rd_namespace_cluster_agent_mappings) { table(:remote_development_namespace_cluster_agent_mappings) } - - let!(:organization) { organizations.create!(name: 'organization', path: 'organization') } - - let!(:namespace) do - namespaces.create!(name: 'root', path: 'root', type: 'Group', organization_id: organization.id).tap do |new_group| - new_group.update!(traversal_ids: [new_group.id]) - end - end - - let!(:nested_group) do - namespaces.create!( - name: 'nested', - path: 'root/nested', - type: 'Group', - organization_id: organization.id - ).tap do |new_group| - new_group.update!(traversal_ids: [namespace.id, new_group.id]) - end - end - - let!(:project) do - projects.create!( - organization_id: organization.id, - namespace_id: nested_group.id, - project_namespace_id: nested_group.id, - name: 'agent project', - path: 'agent-project' - ) - end - - let!(:agent) do - cluster_agents.create!( - name: 'agent with remote dev enabled', - project_id: project.id - ) - end - - let!(:rd_agent_config) do - rd_agent_configs.create!( - cluster_agent_id: agent.id, - enabled: true, - dns_zone: "www.example.com" - ) - end - - let(:all_rd_agent_configs) { [rd_agent_config] } - let(:migration_attrs) do - { - start_id: all_rd_agent_configs.minimum(:id), - end_id: all_rd_agent_configs.maximum(:id), - batch_table: :remote_development_agent_configs, - batch_column: :id, - sub_batch_size: 100, - pause_ms: 0, - connection: ApplicationRecord.connection - } - end - - let(:migration) { described_class.new(**migration_attrs) } - - describe '#perform' do - shared_examples "skipped migration" do - it 'skips migration for such records' do - migration.perform - - expect( - rd_namespace_cluster_agent_mappings - .where(namespace_id: namespace.id, cluster_agent_id: agent.id) - .count - ).to eq(0) - end - end - - context 'when remote dev is enabled for an agent project that resides within a group' do - it 'create a mapping from the cluster agent to its root namespace' do - migration.perform - - migrated_records = rd_namespace_cluster_agent_mappings - .where(namespace_id: namespace.id, cluster_agent_id: agent.id) - expect(migrated_records.count).to eq(1) - expect(migrated_records.first.creator_id).to eq(::Users::Internal.migration_bot.id) - end - end - - context 'when rd-enabled cluster agent project resides within a user namespace' do - let!(:namespace) do - namespaces.create!(name: 'user-namespace', path: 'user-namespace', type: 'User').tap do |new_namespace| - new_namespace.update!(traversal_ids: [new_namespace.id]) - end - end - - it_behaves_like "skipped migration" - end - - context 'when remote dev is disabled for an agent within a group' do - let!(:rd_agent_config) do - rd_agent_configs.create!( - cluster_agent_id: agent.id, - enabled: false, - dns_zone: "www.example.com" - ) - end - - it_behaves_like "skipped migration" - end - - context 'when mapping already exists between an agent and the root namespace' do - let!(:existing_mapping) do - rd_namespace_cluster_agent_mappings.create!( - cluster_agent_id: agent.id, - namespace_id: namespace.id, - creator_id: ::Users::Internal.admin_bot.id - ) - end - - it 'skips migration for such records' do - migration.perform - - mappings = rd_namespace_cluster_agent_mappings.where(namespace_id: namespace.id, cluster_agent_id: agent.id) - expect(mappings.count).to eq(1) - expect(mappings.first.creator_id).to eq(::Users::Internal.admin_bot.id) - expect(mappings.first.created_at).to be_within(0.00001.seconds).of(existing_mapping.created_at) - expect(mappings.first.updated_at).to be_within(0.00001.seconds).of(existing_mapping.updated_at) - end - end - - context 'when candidate remote dev agents exist in multiple root namespaces' do - let!(:namespace2) do - namespaces.create!(name: 'root-group-2', path: 'root2', type: 'Group').tap do |new_group| - new_group.update!(traversal_ids: [new_group.id]) - end - end - - let!(:project2) do - projects.create!( - organization_id: organization.id, - namespace_id: namespace2.id, - project_namespace_id: namespace2.id, - name: 'agent project 2', - path: 'agent-project-2' - ) - end - - let!(:agent2) do - cluster_agents.create!( - name: 'agent 2 with remote dev enabled', - project_id: project2.id - ) - end - - let!(:rd_agent_config2) do - rd_agent_configs.create!( - cluster_agent_id: agent2.id, - enabled: true, - dns_zone: "www.example2.com" - ) - end - - let!(:agent3) do - cluster_agents.create!( - name: 'agent 3 with remote dev enabled', - project_id: project.id - ) - end - - let!(:rd_agent_config3) do - rd_agent_configs.create!( - cluster_agent_id: agent3.id, - enabled: true, - dns_zone: "www.example3.com" - ) - end - - let(:all_rd_agent_configs) { [rd_agent_config, rd_agent_config2, rd_agent_config3] } - - it 'carries out migration for all agent configs' do - migration.perform - - expect(rd_namespace_cluster_agent_mappings.all.count).to eq(3) - expect( - rd_namespace_cluster_agent_mappings - .where(namespace_id: namespace2.id, cluster_agent_id: agent2.id) - .count - ).to eq(1) - expect( - rd_namespace_cluster_agent_mappings - .where(namespace_id: namespace.id, cluster_agent_id: agent.id) - .count - ).to eq(1) - expect( - rd_namespace_cluster_agent_mappings - .where(namespace_id: namespace.id, cluster_agent_id: agent3.id) - .count - ).to eq(1) - end - end - end -end diff --git a/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/create/main_integration_spec.rb b/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/create/main_integration_spec.rb index e96d5e8e969a992bad8fb0cb7a031b48e7d251f0..8c2e86fd67bbe8130e9d6f68b50a08b48f94102b 100644 --- a/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/create/main_integration_spec.rb +++ b/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/create/main_integration_spec.rb @@ -19,7 +19,7 @@ context 'when params are valid' do it 'creates a new mapping for the given namespace and cluster agent and returns success' do - expect { response }.to change { RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping.count }.by(1) + expect { response }.to change { RemoteDevelopment::NamespaceClusterAgentMapping.count }.by(1) expect(response.fetch(:status)).to eq(:success) expect(response[:message]).to be_nil @@ -44,7 +44,7 @@ let(:cluster_agent) { create(:cluster_agent) } it 'does not create the mapping and returns an error' do - expect { response }.not_to change { RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping.count } + expect { response }.not_to change { RemoteDevelopment::NamespaceClusterAgentMapping.count } expect(response).to eq({ status: :error, @@ -61,7 +61,7 @@ end it 'does not create the mapping and returns an error' do - expect { response }.not_to change { RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping.count } + expect { response }.not_to change { RemoteDevelopment::NamespaceClusterAgentMapping.count } expect(response).to eq({ status: :error, diff --git a/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/create/mapping_creator_spec.rb b/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/create/mapping_creator_spec.rb index 5e0ac3897549e15372768525daca420af2994f36..4ef376dc7eb152175df34c8d4cb239228aa1d9b7 100644 --- a/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/create/mapping_creator_spec.rb +++ b/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/create/mapping_creator_spec.rb @@ -28,7 +28,7 @@ context 'when the mapping creation fails' do shared_examples 'err result' do |expected_error_details:| it 'does not create the db records and returns an error result containing a failed message with model errors' do - expect { result }.not_to change { RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping.count } + expect { result }.not_to change { RemoteDevelopment::NamespaceClusterAgentMapping.count } expect(result).to be_err_result do |message| expect(message).to be_a(RemoteDevelopment::Messages::NamespaceClusterAgentMappingCreateFailed) diff --git a/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/main_integration_spec.rb b/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/main_integration_spec.rb index c4f41fb77f0a7bc9bbace627e3f4e5719c1cbba0..73f94f23cf97ad0627de300e3af018e6faf030e6 100644 --- a/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/main_integration_spec.rb +++ b/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/main_integration_spec.rb @@ -17,7 +17,7 @@ context 'when params are valid' do it 'deletes an existing mapping for a given namespace and cluster_agent' do - expect { response }.to change { RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping.count }.by(-1) + expect { response }.to change { RemoteDevelopment::NamespaceClusterAgentMapping.count }.by(-1) expect(response.fetch(:status)).to eq(:success) expect(response[:message]).to be_nil @@ -32,7 +32,7 @@ end it 'does not create the mapping and returns an error' do - expect { response }.not_to change { RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping.count } + expect { response }.not_to change { RemoteDevelopment::NamespaceClusterAgentMapping.count } expect(response).to eq({ status: :error, diff --git a/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/mapping_deleter_spec.rb b/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/mapping_deleter_spec.rb index ea444fe83f1798a798c4c223560d07be5ed4aa80..f8e7a4b1134d23be9d84a630e85c828e2b77525e 100644 --- a/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/mapping_deleter_spec.rb +++ b/ee/spec/lib/remote_development/namespace_cluster_agent_mapping_operations/delete/mapping_deleter_spec.rb @@ -24,7 +24,7 @@ let(:creator) { create(:user) } before do - RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping.new( + RemoteDevelopment::NamespaceClusterAgentMapping.new( namespace_id: namespace.id, cluster_agent_id: agent.id, creator_id: creator.id diff --git a/ee/spec/models/remote_development/remote_development_namespace_cluster_agent_mapping_spec.rb b/ee/spec/models/remote_development/namespace_cluster_agent_mapping_spec.rb similarity index 79% rename from ee/spec/models/remote_development/remote_development_namespace_cluster_agent_mapping_spec.rb rename to ee/spec/models/remote_development/namespace_cluster_agent_mapping_spec.rb index 86731d03a270b86cd31d1042017fc5b8181e46d9..e043715acadfb0c9e721d97660b51ed4f38a4297 100644 --- a/ee/spec/models/remote_development/remote_development_namespace_cluster_agent_mapping_spec.rb +++ b/ee/spec/models/remote_development/namespace_cluster_agent_mapping_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' # noinspection RubyArgCount -- Rubymine detecting wrong types, it thinks some #create are from Minitest, not FactoryBot -RSpec.describe RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping, feature_category: :workspaces do +RSpec.describe RemoteDevelopment::NamespaceClusterAgentMapping, feature_category: :workspaces do let_it_be(:user) { create(:user) } let_it_be_with_reload(:namespace) { create(:group) } let_it_be_with_reload(:agent) { create(:cluster_agent) } @@ -24,13 +24,13 @@ .to belong_to(:user) .class_name('User') .with_foreign_key(:creator_id) - .inverse_of(:created_remote_development_namespace_cluster_agent_mappings) + .inverse_of(:created_namespace_cluster_agent_mappings) end it "belongs to namespace" do is_expected .to belong_to(:namespace) - .inverse_of(:remote_development_namespace_cluster_agent_mappings) + .inverse_of(:namespace_cluster_agent_mappings) end it "belongs to agent" do @@ -38,7 +38,7 @@ .to belong_to(:agent) .class_name('Clusters::Agent') .with_foreign_key(:cluster_agent_id) - .inverse_of(:remote_development_namespace_cluster_agent_mappings) + .inverse_of(:namespace_cluster_agent_mappings) end end diff --git a/ee/spec/requests/api/graphql/mutations/remote_development/namespace_cluster_agent_mapping_operations/create_spec.rb b/ee/spec/requests/api/graphql/mutations/remote_development/namespace_cluster_agent_mapping_operations/create_spec.rb index 4efe5d80a6740059d0186be7c6c1b130e418f968..0c345acdf747650bf1ad5b62989e6df9b423084d 100644 --- a/ee/spec/requests/api/graphql/mutations/remote_development/namespace_cluster_agent_mapping_operations/create_spec.rb +++ b/ee/spec/requests/api/graphql/mutations/remote_development/namespace_cluster_agent_mapping_operations/create_spec.rb @@ -20,7 +20,7 @@ let(:stub_service_response) { ServiceResponse.success(payload: stub_service_payload) } let(:created_mapping) do - instance_double(RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping) + instance_double(RemoteDevelopment::NamespaceClusterAgentMapping) end let(:all_mutation_args) do diff --git a/lib/gitlab/background_migration/backfill_root_namespace_cluster_agent_mappings.rb b/lib/gitlab/background_migration/backfill_root_namespace_cluster_agent_mappings.rb deleted file mode 100644 index 3e143ba2534ba5ee6eaf10d5ec541fed124ef62c..0000000000000000000000000000000000000000 --- a/lib/gitlab/background_migration/backfill_root_namespace_cluster_agent_mappings.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module BackgroundMigration - # Backfills mappings between root namespaces and all agents within the root namespace - # that have remote development module enabled - # For more details, check: https://gitlab.com/gitlab-org/gitlab/-/issues/454411 - class BackfillRootNamespaceClusterAgentMappings < BatchedMigrationJob - feature_category :workspaces - - def perform; end - end - end -end - -Gitlab::BackgroundMigration::BackfillRootNamespaceClusterAgentMappings.prepend_mod diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index e14cc2e80c23ba5b0d21872b0c617ce0d85ad9c7..9eeec0482ed772fc9de463dbe8686e5c77687ccd 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -12,9 +12,7 @@ module Database # TABLES_TO_BE_RENAMED = { # 'old_name' => 'new_name' # }.freeze - TABLES_TO_BE_RENAMED = { - 'remote_development_namespace_cluster_agent_mappings' => 'namespace_cluster_agent_mappings' - }.freeze + TABLES_TO_BE_RENAMED = {}.freeze # Minimum PostgreSQL version requirement per documentation: # https://docs.gitlab.com/ee/install/requirements.html#postgresql-requirements diff --git a/spec/migrations/20240711035245_queue_backfill_root_namespace_cluster_agent_mappings_again_spec.rb b/spec/migrations/20240711035245_queue_backfill_root_namespace_cluster_agent_mappings_again_spec.rb deleted file mode 100644 index 493245824250c193d2f39e20c5c88f8aaaf4ec4a..0000000000000000000000000000000000000000 --- a/spec/migrations/20240711035245_queue_backfill_root_namespace_cluster_agent_mappings_again_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -require_migration! - -RSpec.describe QueueBackfillRootNamespaceClusterAgentMappingsAgain, migration: :gitlab_main_cell, - feature_category: :workspaces do - let!(:batched_migration) { described_class::MIGRATION } - - it 'schedules a new batched migration' do - reversible_migration do |migration| - migration.before -> { - expect(batched_migration).not_to have_scheduled_batched_migration - } - - migration.after -> { - expect(batched_migration).to have_scheduled_batched_migration( - table_name: :remote_development_agent_configs, - column_name: :id, - interval: described_class::DELAY_INTERVAL, - batch_size: described_class::BATCH_SIZE, - gitlab_schema: :gitlab_main_cell, - sub_batch_size: described_class::SUB_BATCH_SIZE - ) - } - end - end -end