Skip to content

Refactor use of Zoekt::IndexedNamespace into module

What does this MR do and why?

Related to #424121 (closed)

This MR:

  • creates a new module that will be used to allow containers (Namespace and Project) to interact with Zoekt nodes. Specifically to find nodes and check whether the container is indexed or searchable in Zoekt.
  • creates a new finder that is used to find zoekt indexed namespaces

Note: the change is an intermediate step before creating a few new tables in the related issue to allow an easier transition

Screenshots or screen recordings

N/A - no UI changes

How to set up and validate locally

This is an underlying code change and introduces no new behavior. Relying upon specs for most checks.

To test functionality for Zoekt search and index:

  1. enable zoekt in gdk
  2. configure zoekt in your environment
  3. enable it for a namespace
  4. verify that search works for the enabled namespace (if search returns results, indexing is working)

Database

Queries for the new finder

when a container is provided, both run the same underlying query

::Search::Zoekt::IndexedNamespacesFinder.new(container: project).execute
::Search::Zoekt::IndexedNamespacesFinder.new(container: group).execute

https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/24735/commands/78636

SELECT
    "zoekt_indexed_namespaces"."id",
    "zoekt_indexed_namespaces"."namespace_id",
    "zoekt_indexed_namespaces"."created_at",
    "zoekt_indexed_namespaces"."updated_at",
    "zoekt_indexed_namespaces"."search",
    "zoekt_indexed_namespaces"."zoekt_node_id"
FROM
    "zoekt_indexed_namespaces"
WHERE
    "zoekt_indexed_namespaces"."namespace_id" = 9970

when no container is provided

::Search::Zoekt::IndexedNamespacesFinder.new(container: nil).execute
SELECT
    "zoekt_indexed_namespaces"."id",
    "zoekt_indexed_namespaces"."namespace_id",
    "zoekt_indexed_namespaces"."created_at",
    "zoekt_indexed_namespaces"."updated_at",
    "zoekt_indexed_namespaces"."search",
    "zoekt_indexed_namespaces"."zoekt_node_id"
FROM
    "zoekt_indexed_namespaces"

https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/24735/commands/78637

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Terri Chu

Merge request reports