From ca9ba4709a4eceff0716198bdd69ad11a076fc01 Mon Sep 17 00:00:00 2001 From: Chen Zhang Date: Wed, 17 Dec 2025 23:42:24 +0000 Subject: [PATCH 1/4] Remove gitlab_main_clusterwide from application code Step 2 of removing deprecated gitlab_main_clusterwide schema references. This commit: - Removes the Danger plugin that warned about gitlab_main_clusterwide usage - Removes gitlab_main_clusterwide from the schema mapping in query analyzers - Removes the test table prefix mapping for _test_gitlab_main_clusterwide_ Related to #583699 --- danger/plugins/gitlab_schema_validation.rb | 9 ----- lib/gitlab/database/gitlab_schema.rb | 1 - .../restrict_allowed_schemas.rb | 1 - .../gitlab_schema_validation_suggestion.rb | 35 ------------------- 4 files changed, 46 deletions(-) delete mode 100644 danger/plugins/gitlab_schema_validation.rb delete mode 100644 tooling/danger/gitlab_schema_validation_suggestion.rb diff --git a/danger/plugins/gitlab_schema_validation.rb b/danger/plugins/gitlab_schema_validation.rb deleted file mode 100644 index ca4bc1a12be365..00000000000000 --- a/danger/plugins/gitlab_schema_validation.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../tooling/danger/gitlab_schema_validation_suggestion' - -module Danger - class GitlabSchemaValidation < ::Danger::Plugin - include Tooling::Danger::GitlabSchemaValidationSuggestion - end -end diff --git a/lib/gitlab/database/gitlab_schema.rb b/lib/gitlab/database/gitlab_schema.rb index 52fb75a4a570ca..de993b78c79321 100644 --- a/lib/gitlab/database/gitlab_schema.rb +++ b/lib/gitlab/database/gitlab_schema.rb @@ -27,7 +27,6 @@ def self.table_schemas!(tables) # It maps table names prefixes to gitlab_schemas. # The order of keys matter. Prefixes that contain other prefixes should come first. IMPLICIT_GITLAB_SCHEMAS = { - '_test_gitlab_main_clusterwide_' => :gitlab_main_clusterwide, '_test_gitlab_main_cell_' => :gitlab_main_cell, '_test_gitlab_main_org_' => :gitlab_main_org, '_test_gitlab_main_' => :gitlab_main, diff --git a/lib/gitlab/database/query_analyzers/restrict_allowed_schemas.rb b/lib/gitlab/database/query_analyzers/restrict_allowed_schemas.rb index 9ec48c8ca07fa5..820b536858e9f9 100644 --- a/lib/gitlab/database/query_analyzers/restrict_allowed_schemas.rb +++ b/lib/gitlab/database/query_analyzers/restrict_allowed_schemas.rb @@ -19,7 +19,6 @@ class RestrictAllowedSchemas < Base gitlab_internal: nil, # Cells specific changes - gitlab_main_clusterwide: :gitlab_main, gitlab_main_cell: :gitlab_main, gitlab_main_org: :gitlab_main, gitlab_main_cell_local: :gitlab_main, diff --git a/tooling/danger/gitlab_schema_validation_suggestion.rb b/tooling/danger/gitlab_schema_validation_suggestion.rb deleted file mode 100644 index 0806bc51fb3c0a..00000000000000 --- a/tooling/danger/gitlab_schema_validation_suggestion.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -require_relative 'suggestion' - -module Tooling - module Danger - module GitlabSchemaValidationSuggestion - include ::Tooling::Danger::Suggestor - - MATCH = %r{gitlab_schema: gitlab_main_clusterwide} - REPLACEMENT = nil - DB_DOCS_PATH = %r{\Adb/docs/[^/]+\.ya?ml\z} - - SUGGESTION = <<~MESSAGE_MARKDOWN - :warning: You have added `gitlab_main_clusterwide` (deprecated) as the schema for this table. We expect most tables to use the - `gitlab_main_org` schema instead. - - Please see the [guidelines on choosing gitlab schema](https://docs.gitlab.com/ee/development/cells/#what-schema-to-choose-if-the-feature-can-be-cluster-wide) for more information. - - Please consult with `@gitlab-com/gl-infra/tenant-scale/cells-infrastructure` if you believe that the clusterwide schema is the best fit for this table. - MESSAGE_MARKDOWN - - def add_suggestions_on_using_clusterwide_schema - helper.all_changed_files.grep(DB_DOCS_PATH).each do |filename| - add_suggestion( - filename: filename, - regex: MATCH, - replacement: REPLACEMENT, - comment_text: SUGGESTION - ) - end - end - end - end -end -- GitLab From 246c04c1373c2fbad12945e25d81af7a3d170a14 Mon Sep 17 00:00:00 2001 From: Chen Zhang Date: Thu, 18 Dec 2025 02:28:53 +0000 Subject: [PATCH 2/4] Delete spec file for removed gitlab_schema_validation_suggestion The implementation file was removed but the spec file was left behind, causing CI failures due to LoadError when trying to require the non-existent file. --- ...itlab_schema_validation_suggestion_spec.rb | 108 ------------------ 1 file changed, 108 deletions(-) delete mode 100644 spec/tooling/danger/gitlab_schema_validation_suggestion_spec.rb diff --git a/spec/tooling/danger/gitlab_schema_validation_suggestion_spec.rb b/spec/tooling/danger/gitlab_schema_validation_suggestion_spec.rb deleted file mode 100644 index 759188176b43d0..00000000000000 --- a/spec/tooling/danger/gitlab_schema_validation_suggestion_spec.rb +++ /dev/null @@ -1,108 +0,0 @@ -# frozen_string_literal: true - -require 'fast_spec_helper' -require 'gitlab/dangerfiles/spec_helper' - -require_relative '../../../tooling/danger/gitlab_schema_validation_suggestion' -require_relative '../../../tooling/danger/project_helper' - -RSpec.describe Tooling::Danger::GitlabSchemaValidationSuggestion, feature_category: :cell do - include_context "with dangerfile" - - let(:fake_danger) { DangerSpecHelper.fake_danger.include(described_class) } - let(:fake_project_helper) { instance_double(Tooling::Danger::ProjectHelper) } - let(:filename) { 'db/docs/application_settings.yml' } - let(:file_lines) do - file_diff.map { |line| line.delete_prefix('+') } - end - - let(:file_diff) do - [ - "+---", - "+table_name: application_settings", - "+classes:", - "+- ApplicationSetting", - "+feature_categories:", - "+- continuous_integration", - "+description: GitLab application settings", - "+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/8589b4e137f50293952923bb07e2814257d7784d", - "+milestone: '7.7'", - "+gitlab_schema: #{schema}" - ] - end - - subject(:gitlab_schema_validation) { fake_danger.new(helper: fake_helper) } - - before do - allow(gitlab_schema_validation).to receive(:project_helper).and_return(fake_project_helper) - allow(gitlab_schema_validation.project_helper).to receive(:file_lines).and_return(file_lines) - allow(gitlab_schema_validation.helper).to receive(:changed_lines).with(filename).and_return(file_diff) - allow(gitlab_schema_validation.helper).to receive(:all_changed_files).and_return([filename]) - end - - shared_examples_for 'does not add a comment' do - it do - expect(gitlab_schema_validation).not_to receive(:markdown) - - gitlab_schema_validation.add_suggestions_on_using_clusterwide_schema - end - end - - context 'for discouraging the use of gitlab_main_clusterwide schema' do - let(:schema) { 'gitlab_main_clusterwide' } - - context 'when the file path matches' do - it 'adds the comment' do - expected_comment = "\n#{described_class::SUGGESTION.chomp}" - - expect(gitlab_schema_validation).to receive(:markdown).with(expected_comment, file: filename, line: 10) - - gitlab_schema_validation.add_suggestions_on_using_clusterwide_schema - end - end - - context 'when the file path does not match' do - let(:filename) { 'some_path/application_settings.yml' } - - it_behaves_like 'does not add a comment' - end - - context 'for EE' do - let(:filename) { 'ee/db/docs/application_settings.yml' } - - it_behaves_like 'does not add a comment' - end - - context 'for a deleted table' do - let(:filename) { 'db/docs/deleted_tables/application_settings.yml' } - - it_behaves_like 'does not add a comment' - end - end - - context 'on removing the gitlab_main_clusterwide schema' do - let(:file_diff) do - [ - "+---", - "+table_name: application_settings", - "+classes:", - "+- ApplicationSetting", - "+feature_categories:", - "+- continuous_integration", - "+description: GitLab application settings", - "+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/commit/8589b4e137f50293952923bb07e2814257d7784d", - "+milestone: '7.7'", - "-gitlab_schema: gitlab_main_clusterwide", - "+gitlab_schema: gitlab_main_org" - ] - end - - it_behaves_like 'does not add a comment' - end - - context 'when a different schema is added' do - let(:schema) { 'gitlab_main' } - - it_behaves_like 'does not add a comment' - end -end -- GitLab From d4390b138871d81af0c0f9d2611e60e44f2518f3 Mon Sep 17 00:00:00 2001 From: Chen Zhang Date: Thu, 18 Dec 2025 02:38:41 +0000 Subject: [PATCH 3/4] Remove gitlab_schema_validation Dangerfile The Dangerfile calls the gitlab_schema_validation plugin which was removed in this MR. Delete the Dangerfile to fix the danger-review pipeline failure. --- danger/gitlab_schema_validation/Dangerfile | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 danger/gitlab_schema_validation/Dangerfile diff --git a/danger/gitlab_schema_validation/Dangerfile b/danger/gitlab_schema_validation/Dangerfile deleted file mode 100644 index 3d44ad592ae872..00000000000000 --- a/danger/gitlab_schema_validation/Dangerfile +++ /dev/null @@ -1,3 +0,0 @@ -# frozen_string_literal: true - -gitlab_schema_validation.add_suggestions_on_using_clusterwide_schema -- GitLab From 088f35160b935d267c822702fdb7594e9c60ac1f Mon Sep 17 00:00:00 2001 From: Chen Zhang Date: Thu, 18 Dec 2025 02:55:53 +0000 Subject: [PATCH 4/4] Remove gitlab_main_clusterwide from test specs Since gitlab_main_clusterwide schema is being deprecated and removed, the corresponding test cases that expect this schema to exist need to be removed as well. This commit removes: - Test case for _test_gitlab_main_clusterwide_table mapping in gitlab_schema_spec.rb - Test expectations for gitlab_main_clusterwide in restrict_allowed_schemas_spec.rb --- spec/lib/gitlab/database/gitlab_schema_spec.rb | 1 - .../database/query_analyzers/restrict_allowed_schemas_spec.rb | 4 ---- 2 files changed, 5 deletions(-) diff --git a/spec/lib/gitlab/database/gitlab_schema_spec.rb b/spec/lib/gitlab/database/gitlab_schema_spec.rb index 8899d7ec0b8f14..d35416071a3df1 100644 --- a/spec/lib/gitlab/database/gitlab_schema_spec.rb +++ b/spec/lib/gitlab/database/gitlab_schema_spec.rb @@ -38,7 +38,6 @@ 'audit_events_part_5fc467ac26' | :gitlab_main '_test_gitlab_main_table' | :gitlab_main '_test_gitlab_ci_table' | :gitlab_ci - '_test_gitlab_main_clusterwide_table' | :gitlab_main_clusterwide '_test_gitlab_main_cell_table' | :gitlab_main_cell '_test_gitlab_main_org_table' | :gitlab_main_org '_test_gitlab_pm_table' | :gitlab_pm diff --git a/spec/lib/gitlab/database/query_analyzers/restrict_allowed_schemas_spec.rb b/spec/lib/gitlab/database/query_analyzers/restrict_allowed_schemas_spec.rb index 59a6ce663f5fa5..14006905d94d8e 100644 --- a/spec/lib/gitlab/database/query_analyzers/restrict_allowed_schemas_spec.rb +++ b/spec/lib/gitlab/database/query_analyzers/restrict_allowed_schemas_spec.rb @@ -16,7 +16,6 @@ expected_allowed_gitlab_schemas: { no_schema: :dml_not_allowed, gitlab_main: :success, - gitlab_main_clusterwide: :success, gitlab_main_cell: :success, gitlab_main_org: :success, gitlab_ci: :dml_access_denied # cross-schema access @@ -27,7 +26,6 @@ expected_allowed_gitlab_schemas: { no_schema: :dml_not_allowed, gitlab_main: :success, - gitlab_main_clusterwide: :success, gitlab_main_cell: :success, gitlab_main_org: :success, gitlab_ci: :dml_access_denied # cross-schema access @@ -38,7 +36,6 @@ expected_allowed_gitlab_schemas: { no_schema: :dml_not_allowed, gitlab_main: :success, - gitlab_main_clusterwide: :success, gitlab_main_cell: :success, gitlab_main_org: :success, gitlab_ci: :dml_access_denied # cross-schema access @@ -49,7 +46,6 @@ expected_allowed_gitlab_schemas: { no_schema: :dml_not_allowed, gitlab_main: :success, - gitlab_main_clusterwide: :success, gitlab_main_cell: :success, gitlab_main_org: :success, gitlab_ci: :dml_access_denied # cross-schema access -- GitLab