diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-24 06:07:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-24 06:07:44 +0300 |
commit | f41ba400eb6320979eccaec747bc1a80c14fbe15 (patch) | |
tree | 590b37197246762cececd1ad4e0107f88507fe0f | |
parent | 1dd92924325105bb04d8900ac2577e59eb39f603 (diff) |
Add latest changes from gitlab-org/gitlab@master
29 files changed, 205 insertions, 66 deletions
diff --git a/app/views/pwa/manifest.json.erb b/app/views/pwa/manifest.json.erb index e780b13de6e..82730105a53 100644 --- a/app/views/pwa/manifest.json.erb +++ b/app/views/pwa/manifest.json.erb @@ -3,7 +3,7 @@ "name": "<%= appearance_pwa_name %>", "short_name": "<%= appearance_pwa_short_name %>", "description": "<%= appearance_pwa_description %>", - "start_url": "<%= explore_projects_path %>", + "start_url": "<%= root_path %>", "scope": "<%= root_path %>", "display": "browser", "orientation": "any", diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index 500ff39d07e..c758708c58f 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -3801,15 +3801,6 @@ :weight: 1 :idempotent: false :tags: [] -- :name: tasks_to_be_done_create - :worker_name: TasksToBeDone::CreateWorker - :feature_category: :onboarding - :has_external_dependencies: false - :urgency: :low - :resource_boundary: :cpu - :weight: 1 - :idempotent: true - :tags: [] - :name: update_external_pull_requests :worker_name: UpdateExternalPullRequestsWorker :feature_category: :continuous_integration diff --git a/app/workers/tasks_to_be_done/create_worker.rb b/app/workers/tasks_to_be_done/create_worker.rb deleted file mode 100644 index 91046e3cfed..00000000000 --- a/app/workers/tasks_to_be_done/create_worker.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -module TasksToBeDone - class CreateWorker - include ApplicationWorker - - data_consistency :always - idempotent! - feature_category :onboarding - urgency :low - worker_resource_boundary :cpu - - def perform(member_task_id, current_user_id, assignee_ids = []) - # no-op removing - # https://docs.gitlab.com/ee/development/sidekiq/compatibility_across_updates.html#removing-worker-classes - end - end -end diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml index 87b3b7391c2..f1d2588a934 100644 --- a/config/sidekiq_queues.yml +++ b/config/sidekiq_queues.yml @@ -685,8 +685,6 @@ - 1 - - system_hook_push - 1 -- - tasks_to_be_done_create - - 1 - - terraform - 1 - - todos_destroyer diff --git a/db/docs/zoekt_shards.yml b/db/docs/zoekt_shards.yml index 5fe3b469b19..31f918c2a7b 100644 --- a/db/docs/zoekt_shards.yml +++ b/db/docs/zoekt_shards.yml @@ -1,10 +1,11 @@ --- table_name: zoekt_shards classes: -- Zoekt::Shard +- Search::Zoekt::Node feature_categories: - global_search -description: Describes a Zoekt server that will be used for indexing and search for some configured namespaces +description: Describes a Zoekt server that will be used for indexing and search for + some configured namespaces introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105049 milestone: '15.9' gitlab_schema: gitlab_main diff --git a/db/migrate/20231013204933_remove_tasks_to_be_done_worker.rb b/db/migrate/20231013204933_remove_tasks_to_be_done_worker.rb new file mode 100644 index 00000000000..d5e8ecfe370 --- /dev/null +++ b/db/migrate/20231013204933_remove_tasks_to_be_done_worker.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveTasksToBeDoneWorker < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + DEPRECATED_JOB_CLASSES = %w[TasksToBeDone::CreateWorker] + + def up + sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES) + end + + def down + # This migration removes any instances of deprecated workers and cannot be undone. + end +end diff --git a/db/post_migrate/20230918084159_drop_columns_from_geo_node_status_table.rb b/db/post_migrate/20230918084159_drop_columns_from_geo_node_status_table.rb index 54941552ef9..ecd52d9313d 100644 --- a/db/post_migrate/20230918084159_drop_columns_from_geo_node_status_table.rb +++ b/db/post_migrate/20230918084159_drop_columns_from_geo_node_status_table.rb @@ -4,7 +4,7 @@ class DropColumnsFromGeoNodeStatusTable < Gitlab::Database::Migration[2.1] enable_lock_retries! def up - remove_columns :geo_node_statuses, + [ :wikis_checksum_failed_count, :wikis_checksum_mismatch_count, :wikis_checksummed_count, @@ -17,6 +17,9 @@ class DropColumnsFromGeoNodeStatusTable < Gitlab::Database::Migration[2.1] :design_repositories_synced_count, :design_repositories_failed_count, :design_repositories_registry_count + ].each do |column_name| + remove_column :geo_node_statuses, column_name, if_exists: true + end end def down diff --git a/db/post_migrate/20231023113908_add_index_stopping_environments_on_updated_at.rb b/db/post_migrate/20231023113908_add_index_stopping_environments_on_updated_at.rb new file mode 100644 index 00000000000..01fe32d6bd7 --- /dev/null +++ b/db/post_migrate/20231023113908_add_index_stopping_environments_on_updated_at.rb @@ -0,0 +1,18 @@ +# 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 AddIndexStoppingEnvironmentsOnUpdatedAt < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_environments_on_updated_at_for_stopping_state' + + disable_ddl_transaction! + + def up + add_concurrent_index :environments, :updated_at, where: "state = 'stopping'", name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :environments, name: INDEX_NAME + end +end diff --git a/db/schema_migrations/20231013204933 b/db/schema_migrations/20231013204933 new file mode 100644 index 00000000000..d0e92a8935d --- /dev/null +++ b/db/schema_migrations/20231013204933 @@ -0,0 +1 @@ +1358c375db88b2d318448cc748eb233b63781fbcdfdbe18c23275b69a7cd794b
\ No newline at end of file diff --git a/db/schema_migrations/20231023113908 b/db/schema_migrations/20231023113908 new file mode 100644 index 00000000000..bf05644a5ab --- /dev/null +++ b/db/schema_migrations/20231023113908 @@ -0,0 +1 @@ +63d7eb49469273cef193dd7c80f1bac042893f5da544f5066d00175f9e026d48
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 09c8974b20e..458de410588 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -32329,6 +32329,8 @@ CREATE INDEX index_environments_on_state_and_auto_delete_at ON environments USIN CREATE INDEX index_environments_on_state_and_auto_stop_at ON environments USING btree (state, auto_stop_at) WHERE ((auto_stop_at IS NOT NULL) AND ((state)::text = 'available'::text)); +CREATE INDEX index_environments_on_updated_at_for_stopping_state ON environments USING btree (updated_at) WHERE ((state)::text = 'stopping'::text); + CREATE UNIQUE INDEX index_epic_board_list_preferences_on_user_and_list ON boards_epic_list_user_preferences USING btree (user_id, epic_list_id); CREATE UNIQUE INDEX index_epic_board_recent_visits_on_user_group_and_board ON boards_epic_board_recent_visits USING btree (user_id, group_id, epic_board_id); diff --git a/doc/user/project/merge_requests/reviews/index.md b/doc/user/project/merge_requests/reviews/index.md index 0a3efa38440..ea99a386da9 100644 --- a/doc/user/project/merge_requests/reviews/index.md +++ b/doc/user/project/merge_requests/reviews/index.md @@ -26,6 +26,7 @@ For an overview, see [Merge request review](https://www.youtube.com/watch?v=2May > - [Introduced](https://gitlab.com/groups/gitlab-org/modelops/applied-ml/review-recommender/-/epics/3) in GitLab 15.4 as a [Beta](../../../../policy/experiment-beta-support.md#beta) feature [with a flag](../../../../administration/feature_flags.md) named `suggested_reviewers_control`. Disabled by default. > - [Enabled on GitLab.com](https://gitlab.com/gitlab-org/gitlab/-/issues/368356) in GitLab 15.6. > - Beta designation [removed from the UI](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/113058) in GitLab 15.10. +> - Feature flag [removed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/134728) in GitLab 16.6. GitLab uses machine learning to suggest reviewers for your merge request. diff --git a/generator_templates/active_record/migration/create_table_migration.rb.tt b/generator_templates/active_record/migration/create_table_migration.rb.tt index e3eae729139..fbd21c28387 100644 --- a/generator_templates/active_record/migration/create_table_migration.rb.tt +++ b/generator_templates/active_record/migration/create_table_migration.rb.tt @@ -16,6 +16,7 @@ class <%= migration_class_name %> < Gitlab::Database::Migration[<%= Gitlab::Data # To disable transactions uncomment the following line and remove these # comments: # disable_ddl_transaction! + milestone '<%= Gitlab.current_milestone %>' # Add dependent 'batched_background_migrations.queued_migration_version' values. # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] diff --git a/generator_templates/active_record/migration/migration.rb.tt b/generator_templates/active_record/migration/migration.rb.tt index 40481aed6ea..a8e715789e6 100644 --- a/generator_templates/active_record/migration/migration.rb.tt +++ b/generator_templates/active_record/migration/migration.rb.tt @@ -23,6 +23,7 @@ class <%= migration_class_name %> < Gitlab::Database::Migration[<%= Gitlab::Data # Add dependent 'batched_background_migrations.queued_migration_version' values. # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] + milestone '<%= Gitlab.current_milestone %>' <%- if migration_action == 'add' -%> def change diff --git a/lib/generators/gitlab/partitioning/templates/foreign_key_definition.rb.template b/lib/generators/gitlab/partitioning/templates/foreign_key_definition.rb.template index f2f9acea923..a9cf5d085d1 100644 --- a/lib/generators/gitlab/partitioning/templates/foreign_key_definition.rb.template +++ b/lib/generators/gitlab/partitioning/templates/foreign_key_definition.rb.template @@ -1,6 +1,8 @@ # frozen_string_literal: true class <%= migration_class_name %> < Gitlab::Database::Migration[<%= Gitlab::Database::Migration.current_version %>] + milestone '<%= Gitlab.current_milestone %>' + disable_ddl_transaction! SOURCE_TABLE_NAME = :<%= source_table_name %> diff --git a/lib/generators/gitlab/partitioning/templates/foreign_key_index.rb.template b/lib/generators/gitlab/partitioning/templates/foreign_key_index.rb.template index 4896d931333..4ca4dd3c842 100644 --- a/lib/generators/gitlab/partitioning/templates/foreign_key_index.rb.template +++ b/lib/generators/gitlab/partitioning/templates/foreign_key_index.rb.template @@ -1,6 +1,8 @@ # frozen_string_literal: true class <%= migration_class_name %> < Gitlab::Database::Migration[<%= Gitlab::Database::Migration.current_version %>] + milestone '<%= Gitlab.current_milestone %>' + disable_ddl_transaction! INDEX_NAME = :index_<%= source_table_name -%>_on_<%= partitioning_column -%>_<%= foreign_key_column %> diff --git a/lib/generators/gitlab/partitioning/templates/foreign_key_removal.rb.template b/lib/generators/gitlab/partitioning/templates/foreign_key_removal.rb.template index b4e881074ad..16bd2548f18 100644 --- a/lib/generators/gitlab/partitioning/templates/foreign_key_removal.rb.template +++ b/lib/generators/gitlab/partitioning/templates/foreign_key_removal.rb.template @@ -1,6 +1,8 @@ # frozen_string_literal: true class <%= migration_class_name %> < Gitlab::Database::Migration[<%= Gitlab::Database::Migration.current_version %>] + milestone '<%= Gitlab.current_milestone %>' + disable_ddl_transaction! SOURCE_TABLE_NAME = :<%= source_table_name %> diff --git a/lib/generators/gitlab/partitioning/templates/foreign_key_validation.rb.template b/lib/generators/gitlab/partitioning/templates/foreign_key_validation.rb.template index bad7d17a51b..b065f390863 100644 --- a/lib/generators/gitlab/partitioning/templates/foreign_key_validation.rb.template +++ b/lib/generators/gitlab/partitioning/templates/foreign_key_validation.rb.template @@ -1,6 +1,8 @@ # frozen_string_literal: true class <%= migration_class_name %> < Gitlab::Database::Migration[<%= Gitlab::Database::Migration.current_version %>] + milestone '<%= Gitlab.current_milestone %>' + disable_ddl_transaction! TABLE_NAME = :<%= source_table_name %> diff --git a/lib/gitlab.rb b/lib/gitlab.rb index 0875b14f7d0..b98a0207567 100644 --- a/lib/gitlab.rb +++ b/lib/gitlab.rb @@ -16,6 +16,11 @@ module Gitlab Gitlab::VersionInfo.parse(Gitlab::VERSION) end + def self.current_milestone + v = version_info + "#{v.major}.#{v.minor}" + end + def self.pre_release? VERSION.include?('pre') end diff --git a/lib/gitlab/database/migration.rb b/lib/gitlab/database/migration.rb index 41044816de9..1d17c2ca608 100644 --- a/lib/gitlab/database/migration.rb +++ b/lib/gitlab/database/migration.rb @@ -56,6 +56,10 @@ module Gitlab include Gitlab::Database::Migrations::RunnerBackoff::MigrationHelpers end + class V2_2 < V2_1 + include Gitlab::Database::Migrations::MilestoneMixin + end + def self.[](version) version = version.to_s name = "V#{version.tr('.', '_')}" @@ -66,7 +70,7 @@ module Gitlab # The current version to be used in new migrations def self.current_version - 2.1 + 2.2 end end end diff --git a/lib/gitlab/database/migrations/milestone_mixin.rb b/lib/gitlab/database/migrations/milestone_mixin.rb index 10bc0c192e7..17b7c0ccfc2 100644 --- a/lib/gitlab/database/migrations/milestone_mixin.rb +++ b/lib/gitlab/database/migrations/milestone_mixin.rb @@ -19,11 +19,10 @@ module Gitlab end end - def initialize(name = class_name, version = nil, type = nil) + def initialize(name = class_name, version = nil, _type = nil) raise MilestoneNotSetError, "Milestone is not set for #{self.class.name}" if milestone.nil? super(name, version) - @version = Gitlab::Database::Migrations::Version.new(version, milestone, type) end def milestone # rubocop:disable Lint/DuplicateMethods diff --git a/rubocop/cop/migration/migration_with_milestone.rb b/rubocop/cop/migration/migration_with_milestone.rb new file mode 100644 index 00000000000..d06850dee5b --- /dev/null +++ b/rubocop/cop/migration/migration_with_milestone.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module Migration + # Cop that checks that any 2.2+ migration is incldued with a call to 'milestone' + class MigrationWithMilestone < RuboCop::Cop::Base + MSG = 'Version 2.2 migrations must specify a milestone.' + + def_node_matcher :gitlab_migration?, <<-PATTERN + (class (const nil? _) (send (const (const (const nil? :Gitlab) :Database) :Migration) :[] (float $_)) ...) + PATTERN + + def_node_search :milestone_call?, '(begin <(send nil? :milestone (str $_)) ...>)' + + def on_class(node) + version = gitlab_migration?(node) + return unless version && version >= 2.2 + + body_node = node.body + return unless body_node + + add_offense(node, message: MSG) unless milestone_call?(body_node) + end + end + end + end +end diff --git a/spec/db/migration_spec.rb b/spec/db/migration_spec.rb index b7a4a302290..784f8753893 100644 --- a/spec/db/migration_spec.rb +++ b/spec/db/migration_spec.rb @@ -8,7 +8,8 @@ RSpec.describe 'Migrations Validation', feature_category: :database do # The range describes the timestamps that given migration helper can be used let(:all_migration_classes) do { - 2022_12_01_02_15_00.. => Gitlab::Database::Migration[2.1], + 2023_10_10_02_15_00.. => Gitlab::Database::Migration[2.2], + 2022_12_01_02_15_00..2023_11_01_02_15_00 => Gitlab::Database::Migration[2.1], 2022_01_26_21_06_58..2023_01_11_12_45_12 => Gitlab::Database::Migration[2.0], 2021_09_01_15_33_24..2022_04_25_12_06_03 => Gitlab::Database::Migration[1.0], 2021_05_31_05_39_16..2021_09_01_15_33_24 => ActiveRecord::Migration[6.1], diff --git a/spec/lib/generators/batched_background_migration/expected_files/queue_my_batched_migration.txt b/spec/lib/generators/batched_background_migration/expected_files/queue_my_batched_migration.txt index aa79062422b..84a3593b4e3 100644 --- a/spec/lib/generators/batched_background_migration/expected_files/queue_my_batched_migration.txt +++ b/spec/lib/generators/batched_background_migration/expected_files/queue_my_batched_migration.txt @@ -5,7 +5,7 @@ # Update below commented lines with appropriate values. -class QueueMyBatchedMigration < Gitlab::Database::Migration[2.1] +class QueueMyBatchedMigration < Gitlab::Database::Migration[2.2] MIGRATION = "MyBatchedMigration" # DELAY_INTERVAL = 2.minutes # BATCH_SIZE = 1000 diff --git a/spec/lib/generators/model/mocks/migration_file.txt b/spec/lib/generators/model/mocks/migration_file.txt index c9e51e51863..d0a5c71ffc3 100644 --- a/spec/lib/generators/model/mocks/migration_file.txt +++ b/spec/lib/generators/model/mocks/migration_file.txt @@ -3,7 +3,7 @@ # See https://docs.gitlab.com/ee/development/migration_style_guide.html # for more information on how to write migrations for GitLab. -class CreateModelGeneratorTestFoos < Gitlab::Database::Migration[2.1] +class CreateModelGeneratorTestFoos < Gitlab::Database::Migration[2.2] # When using the methods "add_concurrent_index" or "remove_concurrent_index" # you must disable the use of transactions # as these methods can not run in an existing transaction. @@ -16,6 +16,7 @@ class CreateModelGeneratorTestFoos < Gitlab::Database::Migration[2.1] # To disable transactions uncomment the following line and remove these # comments: # disable_ddl_transaction! + milestone '16.5' # Add dependent 'batched_background_migrations.queued_migration_version' values. # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] diff --git a/spec/lib/generators/model/model_generator_spec.rb b/spec/lib/generators/model/model_generator_spec.rb index 0e770190d25..7284fc8b28a 100644 --- a/spec/lib/generators/model/model_generator_spec.rb +++ b/spec/lib/generators/model/model_generator_spec.rb @@ -17,6 +17,10 @@ RSpec.describe Model::ModelGenerator do FileUtils.rm_rf(temp_dir) end + before do + allow(Gitlab).to receive(:current_milestone).and_return('16.5') + end + it 'creates the model file with the right content' do subject.invoke_all diff --git a/spec/lib/gitlab/database/migrations/milestone_mixin_spec.rb b/spec/lib/gitlab/database/migrations/milestone_mixin_spec.rb index e375af494a2..87a04329f79 100644 --- a/spec/lib/gitlab/database/migrations/milestone_mixin_spec.rb +++ b/spec/lib/gitlab/database/migrations/milestone_mixin_spec.rb @@ -12,14 +12,11 @@ RSpec.describe Gitlab::Database::Migrations::MilestoneMixin, feature_category: : end let(:migration_mixin) do - Class.new(Gitlab::Database::Migration[2.1]) do - include Gitlab::Database::Migrations::MilestoneMixin - end + Class.new(Gitlab::Database::Migration[2.2]) end let(:migration_mixin_version) do - Class.new(Gitlab::Database::Migration[2.1]) do - include Gitlab::Database::Migrations::MilestoneMixin + Class.new(Gitlab::Database::Migration[2.2]) do milestone '16.4' end end diff --git a/spec/rubocop/cop/migration/migration_with_milestone_spec.rb b/spec/rubocop/cop/migration/migration_with_milestone_spec.rb new file mode 100644 index 00000000000..dd603cad2f8 --- /dev/null +++ b/spec/rubocop/cop/migration/migration_with_milestone_spec.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true + +require 'rubocop_spec_helper' +require_relative '../../../../rubocop/cop/migration/migration_with_milestone' + +RSpec.describe RuboCop::Cop::Migration::MigrationWithMilestone, feature_category: :database do + context 'when we\'re not a Gitlab migration' do + it 'does not register an offense at all' do + expect_no_offenses <<~CODE + class CreateProducts < ActiveRecord::Migration[7.0] + def change + add_column :users, :foo, :integer + end + end + CODE + end + end + + context 'when we\'re a Gitlab migration' do + it 'does not register an offense if we\'re a version before 2.2' do + expect_no_offenses <<~CODE + class TestFoo < Gitlab::Database::Migration[2.1] + def change + add_column :users, :foo, :integer + end + end + CODE + end + + context 'when we\'re version 2.2' do + it 'expects no offense if we call `milestone` with a string' do + expect_no_offenses <<~CODE + class TestFoo < Gitlab::Database::Migration[2.2] + milestone '16.7' + + def change + add_column :users, :foo, :integer + end + end + CODE + end + + it 'expects an offense if we don\'t call `milestone`' do + expect_offense <<~CODE + class TestFoo < Gitlab::Database::Migration[2.2] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG} + def change + add_column :users, :foo, :integer + end + end + CODE + end + + it 'does not matter if include a mixin' do + expect_no_offenses <<~CODE + class TestFoo < Gitlab::Database::Migration[2.2] + include Gitlab::Test::Mixin + + milestone '16.7' + + def change + add_column :users, :foo, :integer + end + end + CODE + end + + it 'does not matter if we call a helper method' do + expect_no_offenses <<~CODE + class TestFoo < Gitlab::Database::Migration[2.2] + disable_ddl_transaction! + + milestone '16.7' + + def change + add_column :users, :foo, :integer + end + end + CODE + end + + it 'does not matter if we include a mixin and call a helper method' do + expect_no_offenses <<~CODE + class TestFoo < Gitlab::Database::Migration[2.2] + include Gitlab::Test::Mixin + + disable_ddl_transaction! + + milestone '16.7' + + def change + add_column :users, :foo, :integer + end + end + CODE + end + end + end +end diff --git a/spec/workers/tasks_to_be_done/create_worker_spec.rb b/spec/workers/tasks_to_be_done/create_worker_spec.rb deleted file mode 100644 index 3a4e10b6a6f..00000000000 --- a/spec/workers/tasks_to_be_done/create_worker_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe TasksToBeDone::CreateWorker, feature_category: :onboarding do - let_it_be(:current_user) { create(:user) } - - let(:assignee_ids) { [1, 2] } - let(:job_args) { [123, current_user.id, assignee_ids] } - - describe '.perform' do - it 'executes the task services for all tasks to be done', :aggregate_failures do - expect { described_class.new.perform(*job_args) }.not_to change { Issue.count } - end - end - - include_examples 'an idempotent worker' do - it 'creates 3 task issues' do - expect { subject }.not_to change { Issue.count } - end - end -end |