Skip to content

Add /admin/search/zoekt APIs for controlling Zoekt rollout

Dylan Griffith requested to merge 404534-zoekt-admin-apis into master

What does this MR do and why?

As part of our rollout of Zoekt we're going to be enabling it 1 namespace at a time. This means that we'll need tooling to simplify this process. Originally I was planning on doing this via the Rails console but I've since learnt any rails console commands require a C2 change request. This requires lots of approvals and someone with access to perform the steps. This seemed quite wasteful so I've subsequently realised this would be better to roll out via chatops. Chatops requires an API to execute the steps so this adds some admin APIs we'd need to run from chatops.

Also these same APIs might end up being useful for other administrators managing Zoekt for their instances or possibly to support a future UI.

NOTE on docs: Since this feature is in early development (alpha) and subject to change until we have done some more internal testing it is minimally documented at https://docs.gitlab.com/ee/user/search/exact_code_search.html . We don't yet have sufficient docs for self-managed on how they would enable this feature so I felt that adding a docs page for this API would probably just cause more confusion so I haven't specifically added anything for this.

See Rollout `search_code_with_zoekt` and `index_cod... (#388519)

New Database queries

  1. Find a Zoekt::Shard
  2. Find all Zoekt::Shard
  3. Find a Zoekt::IndexedNamespace
  4. Find all Zoekt::IndexedNamespace for a Zoekt::Shard limit 20

How to set up and validate locally

  1. Follow the steps at https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/zoekt.md to enable Zoekt in your local environment
  2. Run bin/rspec ee/spec/requests/api/admin/search/zoekt_spec.rb

MR acceptance checklist

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

Related to #404534 (closed)

Edited by Dylan Griffith

Merge request reports