Fix index namespaces for indexing subgroup associations
What does this MR do and why?
Related to #477279 (closed)
This MR fixes a bug where subgroup epics are not being indexed with the gitlab:elastic:index
rake task
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
N/A
How to set up and validate locally
to speed up the index rake task for dev environments, apply the patch below (I'm adding this in another MR)
Click to expand patch
diff --git a/ee/app/workers/search/elastic/trigger_indexing_worker.rb b/ee/app/workers/search/elastic/trigger_indexing_worker.rb
index 6122613e16fd..525cdf1520f6 100644
--- a/ee/app/workers/search/elastic/trigger_indexing_worker.rb
+++ b/ee/app/workers/search/elastic/trigger_indexing_worker.rb
@@ -9,6 +9,7 @@ class TriggerIndexingWorker
INITIAL_TASK = :initiate
TASKS = %i[namespaces projects snippets users].freeze
+ DEFAULT_DELAY = 2.minutes
data_consistency :delayed
@@ -55,15 +56,14 @@ def initiate
).execute
logger.info('Setting `elasticsearch_indexing` has been enabled.')
- self.class.perform_in(2.minutes, INITIAL_TASK, options)
+ reenqueue_initial_task
return false
end
unless ::Gitlab::CurrentSettings.elasticsearch_pause_indexing?
task_executor_service.execute(:pause_indexing)
-
- self.class.perform_in(2.minutes, INITIAL_TASK, options)
+ reenqueue_initial_task
return false
end
@@ -87,6 +87,14 @@ def task_executor_service
def logger
@logger ||= ::Gitlab::Elasticsearch::Logger.build
end
+
+ def reenqueue_initial_task
+ if Rails.env.development?
+ self.class.perform_async(INITIAL_TASK, options)
+ else
+ self.class.perform_in(DEFAULT_DELAY, INITIAL_TASK, options)
+ end
+ end
end
end
end
diff --git a/ee/lib/gitlab/elastic/group_search_results.rb b/ee/lib/gitlab/elastic/group_search_results.rb
index e83c026ffb82..2d075f072ff6 100644
--- a/ee/lib/gitlab/elastic/group_search_results.rb
+++ b/ee/lib/gitlab/elastic/group_search_results.rb
@@ -31,7 +31,7 @@ def scope_options(scope)
case scope
when :users
super.except(:group_ids) # User uses group_id for namespace_query
- when :wiki_blobs, :work_items
+ when :wiki_blobs, :work_items, :epics
super.merge(root_ancestor_ids: [group.root_ancestor.id])
else
super
- enable elasticsearch for gdk
- add a group, and add a subgroup (or use an existing subgroup)
- add an epic to the subgroup
- run the rake task
gitlab:elastic:index
- make sure that the epic from the subgroup is indexed and findable
Note: I tested this on master
and the subgroup epic was not findable (even when limiting is not enabled).
Edited by Terri Chu