Commit a39857d1 authored by Adam Hegyi's avatar Adam Hegyi

Remove optimized_elasticsearch_indexes_project FF

This change removes the optimized_elasticsearch_indexes_project feature
flag.
parent f0550cb6
...@@ -136,10 +136,10 @@ module EE ...@@ -136,10 +136,10 @@ module EE
return false unless elasticsearch_indexing? return false unless elasticsearch_indexing?
return true unless elasticsearch_limit_indexing? return true unless elasticsearch_limit_indexing?
return optimized_elasticsearch_indexes_project?(project) unless ::Feature.enabled?(:elasticsearch_indexes_project_cache, default_enabled: true) return elasticsearch_limited_project_exists?(project) unless ::Feature.enabled?(:elasticsearch_indexes_project_cache, default_enabled: true)
::Gitlab::Elastic::ElasticsearchEnabledCache.fetch(:project, project.id) do ::Gitlab::Elastic::ElasticsearchEnabledCache.fetch(:project, project.id) do
optimized_elasticsearch_indexes_project?(project) elasticsearch_limited_project_exists?(project)
end end
end end
...@@ -298,24 +298,19 @@ module EE ...@@ -298,24 +298,19 @@ module EE
private private
def optimized_elasticsearch_indexes_project?(project) def elasticsearch_limited_project_exists?(project)
if ::Feature.enabled?(:optimized_elasticsearch_indexes_project, default_enabled: true) indexed_namespaces = ::Gitlab::ObjectHierarchy
indexed_namespaces = ::Gitlab::ObjectHierarchy .new(::Namespace.where(id: project.namespace_id))
.new(::Namespace.where(id: project.namespace_id)) .base_and_ancestors
.base_and_ancestors .joins(:elasticsearch_indexed_namespace)
.joins(:elasticsearch_indexed_namespace)
indexed_namespaces = ::Project.where('EXISTS (?)', indexed_namespaces) indexed_namespaces = ::Project.where('EXISTS (?)', indexed_namespaces)
indexed_projects = ::Project.where('EXISTS (?)', ElasticsearchIndexedProject.where(project_id: project.id)) indexed_projects = ::Project.where('EXISTS (?)', ElasticsearchIndexedProject.where(project_id: project.id))
::Project ::Project
.from("(SELECT) as projects") # SELECT from "nothing" since the EXISTS queries have all the conditions. .from("(SELECT) as projects") # SELECT from "nothing" since the EXISTS queries have all the conditions.
.merge(indexed_namespaces.or(indexed_projects)) .merge(indexed_namespaces.or(indexed_projects))
.exists? .exists?
else
# old behavior
elasticsearch_limited_projects.exists?(project.id)
end
end end
def resume_elasticsearch_indexing def resume_elasticsearch_indexing
......
---
title: Remove optimized_elasticsearch_indexes_project feature flag
merge_request: 33965
author:
type: other
...@@ -306,49 +306,31 @@ RSpec.describe ApplicationSetting do ...@@ -306,49 +306,31 @@ RSpec.describe ApplicationSetting do
end end
describe '#elasticsearch_indexes_project?' do describe '#elasticsearch_indexes_project?' do
shared_examples 'examples for #elasticsearch_indexes_project?' do context 'when project is in a subgroup' do
context 'when project is in a subgroup' do let(:root_group) { create(:group) }
let(:root_group) { create(:group) } let(:subgroup) { create(:group, parent: root_group) }
let(:subgroup) { create(:group, parent: root_group) } let(:project) { create(:project, group: subgroup) }
let(:project) { create(:project, group: subgroup) }
before do
create(:elasticsearch_indexed_namespace, namespace: root_group)
end
it 'allows project to be indexed' do
expect(setting.elasticsearch_indexes_project?(project)).to be(true)
end
end
context 'when project is in a namespace' do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, namespace: namespace) }
before do
create(:elasticsearch_indexed_namespace, namespace: namespace)
end
it 'allows project to be indexed' do
expect(setting.elasticsearch_indexes_project?(project)).to be(true)
end
end
end
context 'when optimized_elasticsearch_indexes_project feature flag is on' do
before do before do
stub_feature_flags(optimized_elasticsearch_indexes_project: true) create(:elasticsearch_indexed_namespace, namespace: root_group)
end end
include_examples 'examples for #elasticsearch_indexes_project?' it 'allows project to be indexed' do
expect(setting.elasticsearch_indexes_project?(project)).to be(true)
end
end end
context 'when optimized_elasticsearch_indexes_project feature flag is off' do context 'when project is in a namespace' do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, namespace: namespace) }
before do before do
stub_feature_flags(optimized_elasticsearch_indexes_project: false) create(:elasticsearch_indexed_namespace, namespace: namespace)
end end
include_examples 'examples for #elasticsearch_indexes_project?' it 'allows project to be indexed' do
expect(setting.elasticsearch_indexes_project?(project)).to be(true)
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment