Skip to content
代码片段 群组 项目
未验证 提交 12ec00d4 编辑于 作者: Terri Chu's avatar Terri Chu 提交者: GitLab
浏览文件

Mark 20231005103449 as obsolete

This migration marks the 20231005103449 ReindexAndRemoveLeftoverMergeRequestInMainIndex Advanced search migration as obsolete.

[Search for references to `reindex_and_remove_leftover_merge_request_in_main_index` in code](https://gitlab.com/search?project_id=278964&scope=blobs&search=reindex_and_remove_leftover_merge_request_in_main_index&regex=false))

At the moment, the `gitlab-housekeeper` is not always capable of removing all references so
you must check the diff and pipeline failures to confirm if there are any issues.
It is the responsibility of the assignee (picked from ~"group::global search") to push those changes to this branch.

[Read more](https://docs.gitlab.com/ee/development/search/advanced_search_migration_styleguide.html#cleaning-up-advanced-search-migrations)
about the process for marking Advanced search migrations as obsolete.

All Advanced search migrations must have had at least one
[required stop](https : // docs.gitlab.com / ee / development / database / required_stops.html)
to process the migration. Therefore we mark any Advanced search migrations added before the
last required stop as obsolete.

This change was generated by
[gitlab-housekeeper](https://gitlab.com/gitlab-org/gitlab/-/tree/master/gems/gitlab-housekeeper)
using the Keeps::MarkOldAdvancedSearchMigrationsAsObsolete keep.

To provide feedback on your experience with `gitlab-housekeeper` please create an issue with the
label ~"GitLab Housekeeper" and consider pinging the author of this keep.

Changelog: other
EE: true
上级 ba08035a
No related branches found
No related tags found
无相关合并请求
...@@ -11,7 +11,6 @@ Rails/FindEach: ...@@ -11,7 +11,6 @@ Rails/FindEach:
- 'db/post_migrate/20231003045342_migrate_sidekiq_namespaced_jobs.rb' - 'db/post_migrate/20231003045342_migrate_sidekiq_namespaced_jobs.rb'
- 'ee/app/workers/compliance_management/merge_requests/compliance_violations_consistency_worker.rb' - 'ee/app/workers/compliance_management/merge_requests/compliance_violations_consistency_worker.rb'
- 'ee/lib/ee/gitlab/background_migration/create_compliance_standards_adherence.rb' - 'ee/lib/ee/gitlab/background_migration/create_compliance_standards_adherence.rb'
- 'ee/spec/elastic/migrate/20231005103449_reindex_and_remove_leftover_merge_request_in_main_index_spec.rb'
- 'ee/spec/frontend/fixtures/runner.rb' - 'ee/spec/frontend/fixtures/runner.rb'
- 'ee/spec/lib/ee/gitlab/usage_data_spec.rb' - 'ee/spec/lib/ee/gitlab/usage_data_spec.rb'
- 'ee/spec/requests/api/graphql/ci/jobs_spec.rb' - 'ee/spec/requests/api/graphql/ci/jobs_spec.rb'
......
...@@ -5,6 +5,6 @@ description: Reindex all merge_requests from the main index and remove them ...@@ -5,6 +5,6 @@ description: Reindex all merge_requests from the main index and remove them
group: group::global search group: group::global search
milestone: '16.5' milestone: '16.5'
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/133404 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/133404
obsolete: false obsolete: true
marked_obsolete_by_url: marked_obsolete_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/165988
marked_obsolete_in_milestone: marked_obsolete_in_milestone: '17.5'
...@@ -51,3 +51,5 @@ def index_name ...@@ -51,3 +51,5 @@ def index_name
Elastic::Latest::Config.index_name Elastic::Latest::Config.index_name
end end
end end
ReindexAndRemoveLeftoverMergeRequestInMainIndex.prepend ::Elastic::MigrationObsolete
...@@ -3,119 +3,6 @@ ...@@ -3,119 +3,6 @@
require 'spec_helper' require 'spec_helper'
require File.expand_path('ee/elastic/migrate/20231005103449_reindex_and_remove_leftover_merge_request_in_main_index.rb') require File.expand_path('ee/elastic/migrate/20231005103449_reindex_and_remove_leftover_merge_request_in_main_index.rb')
RSpec.describe ReindexAndRemoveLeftoverMergeRequestInMainIndex, :elastic, :sidekiq_inline, feature_category: :global_search do RSpec.describe ReindexAndRemoveLeftoverMergeRequestInMainIndex, feature_category: :global_search do
let(:version) { 20231005103449 } it_behaves_like 'a deprecated Advanced Search migration', 20231005103449
let(:migration) { described_class.new(version) }
let(:helper) { Gitlab::Elastic::Helper.new }
let(:client) { ::Gitlab::Search::Client.new }
let_it_be(:merge_requests) { create_list(:merge_request, 6) }
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
allow(migration).to receive(:helper).and_return(helper)
allow(migration).to receive(:client).and_return(client)
end
describe 'migration_options' do
it 'has migration options set', :aggregate_failures do
expect(migration.batched?).to be_truthy
expect(migration).to be_retry_on_failure
expect(migration.batch_size).to eq(1000)
expect(migration.throttle_delay).to eq(3.minutes)
end
end
describe '.completed?' do
before do
MergeRequest.all.each { |mr| populate_merge_requests_in_main_index!(mr) }
end
context 'when no merge_request documents are in the main index' do
before do
client.delete_by_query(index: helper.target_name, conflicts: 'proceed', refresh: true,
body: { query: { bool: { filter: { term: { type: 'merge_request' } } } } }
)
end
it 'returns true' do
expect(migration).to be_completed
end
end
context 'when merge_request documents exists in the main index' do
it 'returns false' do
expect(migration).not_to be_completed
end
end
end
describe '.migrate' do
let(:batch_size) { 1 }
before do
allow(migration).to receive(:batch_size).and_return(batch_size)
MergeRequest.all.each { |mr| populate_merge_requests_in_main_index!(mr) }
end
context 'if migration is completed' do
before do
client.delete_by_query(index: helper.target_name, conflicts: 'proceed', refresh: true,
body: { query: { bool: { filter: { term: { type: 'merge_request' } } } } }
)
end
it 'performs logging and does not call Elastic::ProcessBookkeepingService' do
expect(migration).to receive(:log).with("Setting migration_state to #{{ documents_remaining: 0 }.to_json}").once
expect(migration).to receive(:log).with('Checking if migration is finished', { total_remaining: 0 }).once
expect(migration).to receive(:log).with('Migration Completed', { total_remaining: 0 }).once
expect(Elastic::ProcessBookkeepingService).not_to receive(:track!)
migration.migrate
end
end
context 'if migration is not completed' do
it 'calls Elastic::ProcessBookkeepingService' do
initial_documents_left_to_be_indexed_count = documents_left_to_be_indexed_count
expect(initial_documents_left_to_be_indexed_count).to be > 0 # Ensure that the migration is not already finished
expect(Elastic::ProcessBookkeepingService).to receive(:track!).with(anything).once
expect(migration).not_to be_completed
migration.migrate
to_be_indexed_count = initial_documents_left_to_be_indexed_count - batch_size
expect(documents_left_to_be_indexed_count).to eq to_be_indexed_count
expect(migration).not_to be_completed
expect(Elastic::ProcessBookkeepingService).to receive(:track!).with(anything).exactly(to_be_indexed_count).times
10.times do
break if migration.completed?
migration.migrate
sleep 0.01
end
expect(documents_left_to_be_indexed_count).to eq 0
expect(migration).to be_completed
end
end
end
def populate_merge_requests_in_main_index!(mr)
client.index(index: helper.target_name, routing: "project_#{mr.project_id}", id: "merge_request_#{mr.id}",
refresh: true, body: {
id: mr.id, iid: mr.iid, target_branch: mr.target_branch, source_branch: mr.source_branch, title: mr.title,
description: mr.description, state: mr.state, merge_status: mr.merge_status, project_id: mr.project_id,
source_project_id: mr.source_project_id, target_project_id: mr.target_project_id, author_id: mr.author_id,
created_at: mr.created_at.strftime('%Y-%m-%dT%H:%M:%S.%3NZ'), visibility_level: mr.project.visibility_level,
updated_at: mr.updated_at.strftime('%Y-%m-%dT%H:%M:%S.%3NZ'),
join_field: { name: 'merge_request', parent: "project_#{mr.project_id}" }, type: 'merge_request',
merge_requests_access_level: mr.project.merge_requests_access_level
}
)
end
def documents_left_to_be_indexed_count
helper.refresh_index(index_name: helper.target_name)
client.count(index: helper.target_name, body: { query: query })['count']
end
def query
{ bool: { filter: { term: { type: 'merge_request' } } } }
end
end end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册