Zoekt: Add a new setting zoekt_index_all_namespaces
What does this MR do and why?
Why: Currently, the self-managed customers have to manually create ZoektEnabledNamespace
from the rails console. With the help of this option, it would be easier for them to get their namespaces indexed.
What: Add a new setting Automatically index root namespaces
under the Exact code search configuration
. Every 10 minutes
our rake task will check if the setting zoekt_auto_index_root_namespace
is enabled
and if there is any root group that doesn't have zoekt_enabled_namespace
, it will create Search::Zoekt::EnabledNamespace
for that root group. We don't need to run this task on gitlab.com
.
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
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
- Run the gdk and navigate to the http://127.0.0.1:3000/admin/application_settings/advanced_search
- Expand the
Exact code search configuration
. - Uncheck the checkbox
Automatically index root namespaces
- Run the rails console
bin/rails c
- Check if you have a root group which has missing zoekt_enabled_namespace. If not then create a root group from the browser and check it again.
Group.root_groups_without_zoekt_enabled_namespace.any?
- Check the
Search::Zoekt::EnabledNamespace
count
Search::Zoekt::EnabledNamespace.count
- Run the task
Search::Zoekt::SchedulingService.new(:create_zoekt_indexed_namespace_for_self_managed).execute
- Check the
Search::Zoekt::EnabledNamespace
count. It should not be changed
Search::Zoekt::EnabledNamespace.count
- Now check the checkbox
Automatically index root namespaces
under the application setting. - You need to restart the rails console to take effect the Application setting change.
- Run the task again. And check the count of
Search::Zoekt::EnabledNamespace
. It should have been increased. - Check the count of
Group.root_groups_without_zoekt_enabled_namespace
. Should be0
Query plan
SELECT
"namespaces"."id"
FROM
"namespaces"
LEFT OUTER JOIN "zoekt_enabled_namespaces" "zoekt_enabled_namespace" ON "zoekt_enabled_namespace"."root_namespace_id" = "namespaces"."id"
WHERE
"namespaces"."type" = 'Group'
AND "namespaces"."parent_id" IS NULL
AND "zoekt_enabled_namespace"."root_namespace_id" IS NULL
LIMIT 1000
https://console.postgres.ai/shared/00eaba4f-5367-4fd5-bbee-789af7c0a36d
Related to #455533 (closed)