From 6f0447dba04ade76f8ea5fba59bbb48625afb9b6 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 3 Nov 2021 03:13:15 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .gitlab/ci/rails.gitlab-ci.yml | 1 + Gemfile | 2 +- Gemfile.lock | 4 ++-- app/models/ci/application_record.rb | 4 ++++ app/models/ci/ci_database_record.rb | 17 ----------------- app/models/ci/instance_variable.rb | 2 +- doc/administration/repository_storage_paths.md | 2 +- doc/development/database/multiple_databases.md | 10 ---------- lib/gitlab/blob_helper.rb | 2 +- lib/gitlab/database.rb | 2 +- spec/lib/api/ci/helpers/runner_spec.rb | 8 ++++---- .../bare_repository_import/importer_spec.rb | 2 -- spec/lib/gitlab/blob_helper_spec.rb | 12 ++++++++++-- .../load_balancing/configuration_spec.rb | 8 +++++--- .../load_balancing/load_balancer_spec.rb | 6 +++--- spec/lib/gitlab/database/load_balancing_spec.rb | 2 +- .../database/schema_migrations/context_spec.rb | 2 +- spec/lib/marginalia_spec.rb | 6 +++--- spec/models/ci/build_spec.rb | 2 +- spec/models/ci/runner_spec.rb | 2 +- spec/support/helpers/usage_data_helpers.rb | 2 ++ .../lib/gitlab/ci/ci_trace_shared_examples.rb | 16 ++++++++-------- .../database/multiple_databases_spec.rb | 6 +++--- .../usage_trends/counter_job_worker_spec.rb | 3 ++- 24 files changed, 56 insertions(+), 67 deletions(-) delete mode 100644 app/models/ci/ci_database_record.rb diff --git a/.gitlab/ci/rails.gitlab-ci.yml b/.gitlab/ci/rails.gitlab-ci.yml index 5ff387ee3a7..2d6ddf1c997 100644 --- a/.gitlab/ci/rails.gitlab-ci.yml +++ b/.gitlab/ci/rails.gitlab-ci.yml @@ -26,6 +26,7 @@ .decomposed-database-rspec: variables: DECOMPOSED_DB: "true" + GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci: "main" .rspec-base: extends: .rails-job-base diff --git a/Gemfile b/Gemfile index 536060d2b99..6146d6e011f 100644 --- a/Gemfile +++ b/Gemfile @@ -399,7 +399,7 @@ group :development, :test do end group :development, :test, :danger do - gem 'gitlab-dangerfiles', '~> 2.3.2', require: false + gem 'gitlab-dangerfiles', '~> 2.4.0', require: false end group :development, :test, :coverage do diff --git a/Gemfile.lock b/Gemfile.lock index 4cb585a75f5..b82fdfc81c7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -458,7 +458,7 @@ GEM terminal-table (~> 1.5, >= 1.5.1) gitlab-chronic (0.10.5) numerizer (~> 0.2) - gitlab-dangerfiles (2.3.2) + gitlab-dangerfiles (2.4.0) danger (>= 8.3.1) danger-gitlab (>= 8.0.0) gitlab-experiment (0.6.4) @@ -1464,7 +1464,7 @@ DEPENDENCIES gitaly (~> 14.4.0.pre.rc43) github-markup (~> 1.7.0) gitlab-chronic (~> 0.10.5) - gitlab-dangerfiles (~> 2.3.2) + gitlab-dangerfiles (~> 2.4.0) gitlab-experiment (~> 0.6.4) gitlab-fog-azure-rm (~> 1.2.0) gitlab-labkit (~> 0.21.1) diff --git a/app/models/ci/application_record.rb b/app/models/ci/application_record.rb index 9d4a8f0648e..ea7b1104e36 100644 --- a/app/models/ci/application_record.rb +++ b/app/models/ci/application_record.rb @@ -4,6 +4,10 @@ module Ci class ApplicationRecord < ::ApplicationRecord self.abstract_class = true + if Gitlab::Database.has_config?(:ci) + connects_to database: { writing: :ci, reading: :ci } + end + def self.table_name_prefix 'ci_' end diff --git a/app/models/ci/ci_database_record.rb b/app/models/ci/ci_database_record.rb deleted file mode 100644 index e2b832a28e7..00000000000 --- a/app/models/ci/ci_database_record.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -module Ci - # TODO: https://gitlab.com/groups/gitlab-org/-/epics/6168 - # - # Do not use this yet outside of `ci_instance_variables`. - # This class is part of a migration to move all CI classes to a new separate database. - # Initially we are only going to be moving the `Ci::InstanceVariable` model and it will be duplicated in the main and CI tables - # Do not extend this class in any other models. - class CiDatabaseRecord < Ci::ApplicationRecord - self.abstract_class = true - - if Gitlab::Database.has_config?(:ci) - connects_to database: { writing: :ci, reading: :ci } - end - end -end diff --git a/app/models/ci/instance_variable.rb b/app/models/ci/instance_variable.rb index f4aa935b983..da9d4dea537 100644 --- a/app/models/ci/instance_variable.rb +++ b/app/models/ci/instance_variable.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Ci - class InstanceVariable < Ci::CiDatabaseRecord + class InstanceVariable < Ci::ApplicationRecord extend Gitlab::ProcessMemoryCache::Helper include Ci::NewHasVariable include Ci::Maskable diff --git a/doc/administration/repository_storage_paths.md b/doc/administration/repository_storage_paths.md index ed50d0e7263..00aa8c214c5 100644 --- a/doc/administration/repository_storage_paths.md +++ b/doc/administration/repository_storage_paths.md @@ -14,7 +14,7 @@ storage is either: - A `path`, which points directly to the directory where the repositories are stored. GitLab directly accessing a directory containing repositories [is deprecated](https://gitlab.com/gitlab-org/gitaly/-/issues/1690). - GitLab should be configured to access GitLab repositories though a `gitaly_address`. + GitLab should be configured to access GitLab repositories through a `gitaly_address`. GitLab allows you to define multiple repository storages to distribute the storage load between several mount points. For example: diff --git a/doc/development/database/multiple_databases.md b/doc/development/database/multiple_databases.md index e21606bd3e7..a17ad798305 100644 --- a/doc/development/database/multiple_databases.md +++ b/doc/development/database/multiple_databases.md @@ -88,16 +88,6 @@ test: &test statement_timeout: 120s ``` -### Migrations - -Place any migrations that affect `Ci::CiDatabaseRecord` models -and their tables in two directories: - -- `db/migrate` -- `db/ci_migrate` - -We aim to keep the schema for both tables the same across both databases. -