Commit 38c1ed7c authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '216224_remove_optimized_elasticsearch_indexes_project_ff' into 'master'

Remove optimized_elasticsearch_indexes_project FF

See merge request gitlab-org/gitlab!33965
parents 6fd8037f a39857d1
......@@ -136,10 +136,10 @@ module EE
return false unless elasticsearch_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
optimized_elasticsearch_indexes_project?(project)
elasticsearch_limited_project_exists?(project)
end
end
......@@ -298,24 +298,19 @@ module EE
private
def optimized_elasticsearch_indexes_project?(project)
if ::Feature.enabled?(:optimized_elasticsearch_indexes_project, default_enabled: true)
indexed_namespaces = ::Gitlab::ObjectHierarchy
.new(::Namespace.where(id: project.namespace_id))
.base_and_ancestors
.joins(:elasticsearch_indexed_namespace)
def elasticsearch_limited_project_exists?(project)
indexed_namespaces = ::Gitlab::ObjectHierarchy
.new(::Namespace.where(id: project.namespace_id))
.base_and_ancestors
.joins(:elasticsearch_indexed_namespace)
indexed_namespaces = ::Project.where('EXISTS (?)', indexed_namespaces)
indexed_projects = ::Project.where('EXISTS (?)', ElasticsearchIndexedProject.where(project_id: project.id))
indexed_namespaces = ::Project.where('EXISTS (?)', indexed_namespaces)
indexed_projects = ::Project.where('EXISTS (?)', ElasticsearchIndexedProject.where(project_id: project.id))
::Project
.from("(SELECT) as projects") # SELECT from "nothing" since the EXISTS queries have all the conditions.
.merge(indexed_namespaces.or(indexed_projects))
.exists?
else
# old behavior
elasticsearch_limited_projects.exists?(project.id)
end
::Project
.from("(SELECT) as projects") # SELECT from "nothing" since the EXISTS queries have all the conditions.
.merge(indexed_namespaces.or(indexed_projects))
.exists?
end
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
end
describe '#elasticsearch_indexes_project?' do
shared_examples 'examples for #elasticsearch_indexes_project?' do
context 'when project is in a subgroup' do
let(:root_group) { create(:group) }
let(:subgroup) { create(:group, parent: root_group) }
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
context 'when project is in a subgroup' do
let(:root_group) { create(:group) }
let(:subgroup) { create(:group, parent: root_group) }
let(:project) { create(:project, group: subgroup) }
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
stub_feature_flags(optimized_elasticsearch_indexes_project: true)
create(:elasticsearch_indexed_namespace, namespace: root_group)
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
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
stub_feature_flags(optimized_elasticsearch_indexes_project: false)
create(:elasticsearch_indexed_namespace, namespace: namespace)
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
......
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