Skip to content

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
Screenshot_2024-06-06_at_16.31.21 Screenshot_2024-06-07_at_11.01.51

How to set up and validate locally

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 be 0

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)

Edited by Ravi Kumar

Merge request reports

Loading