gitlab-zoekt-indexer

module
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2025 License: MIT

README

gitlab-zoekt

A fast, precise code search solution that integrates Zoekt with GitLab. This project provides the infrastructure for indexing and searching code across GitLab repositories with high performance and accuracy.

Overview

gitlab-zoekt is built on top of Zoekt, a fast code search engine maintained by Sourcegraph. It creates specialized search indexes of GitLab repositories by communicating with Gitaly (GitLab's Git repository storage service) and provides a search API for performing fast, exact and regex searches across indexed code.

Key features:

  • Fast and accurate code search across GitLab repositories
  • Incremental indexing for efficiency (only updating changed files)
  • Scalable architecture supporting distributed searching across multiple nodes

This repository includes three binaries:

  • gitlab-zoekt-indexer: Original indexer binary
  • gitlab-zoekt-webserver: Original webserver binary
  • gitlab-zoekt: New unified binary that can run in either indexer or webserver mode

Documentation overview

Compiling the binaries

# Build the original indexer (deprecated)
$ make build
$ ./bin/gitlab-zoekt-indexer
2023/08/14 11:07:29 Usage: ./bin/gitlab-zoekt-indexer [ --version | --index_dir=<DIR> | --path_prefix=<PREFIX> | --listen=:<PORT> ]

# Build the original webserver (deprecated)
$ make build-web

# Build the unified binary
$ make build-unified
$ ./bin/gitlab-zoekt
Usage: ./bin/gitlab-zoekt <command> [options]

Commands:
  indexer     Run in indexer mode
  webserver   Run in webserver mode
  version     Print version information

For command specific help:
  ./bin/gitlab-zoekt <command> -help

Using the unified binary

The unified binary supports both indexer and webserver modes:

# Run in indexer mode
$ ./bin/gitlab-zoekt indexer -index_dir=/data/index -listen=:6060

# Run in CI/testing mode (skips gitlab_url and self_url requirements)
$ ./bin/gitlab-zoekt indexer -index_dir=/data/index -listen=:6060 -ci

# Run in webserver mode
$ ./bin/gitlab-zoekt webserver -index_dir=/data/index -listen=:6070

# Show help for a specific mode
$ ./bin/gitlab-zoekt indexer -help
$ ./bin/gitlab-zoekt webserver -help

# Show version information
$ ./bin/gitlab-zoekt version

Running indexer in GDK mode

  1. Set GDK_DIR env variable (for example, export GDK_DIR="$HOME/projects/gdk").
  2. Stop GDK zoekt processes if you have it running via
    gdk stop gitlab-zoekt-indexer-development-1 gitlab-zoekt-indexer-development-2 gitlab-zoekt-webserver-development-1 gitlab-zoekt-webserver-development-2
    
  3. Execute make gdk. This will replace GDK processes with the unified binary from this repo.

[!note] If your gitlab is different from http://localhost:3000, please also set GDK_GITLAB_URL. For example: export GDK_GITLAB_URL="https://gdk.test:3443"

Running indexer with docker-compose

For trying out zoekt. Not an official installation method.

See example

Running tests

  1. Install a suitable docker client
  2. Compile the unified binary
    make build-unified
    
  3. Run the dependencies:
    docker-compose up
    
  4. Run the tests:
    # One time
    make test
    
    # On every change (requires https://github.com/watchexec/watchexec installed)
    make watch-test
    

Updating the shard test fixture

  1. Build a binary in sourcegraph/zoekt project
    go build -o zoekt-index ./cmd/zoekt-index
    
  2. Index a code repository using the binary. Notice that we are specifying a meta file in the command line arguments.
./zoekt-index -index /tmp/.zoekt -meta ~/code/gitlab-zoekt/_support/test/309.meta.json ~/code/gitlab-zoekt

Release Process

In order to release the changes to GitLab.com production, follow these steps:

  1. Bump up the VERSION file in this repository following semantic versioning

  2. Update the version file in the monolith Note: MR is created automatically via Renovate bot.

    Changing this allows the Monolith run specs against the newer Zoekt Indexer. This file is also planned to be used for OmniBus in the future, to indicate which Zoekt Indexer to run.

  3. Prepare a CNG MR to release a new image. Example: !2533

  4. Deploy to GSTG by updating gstg.zoekt-versions.yaml. Example MR: !4607

  5. Deploy to GPRD by updating gprd.zoekt-versions.yaml. Example MR: !4616

After we verify that everything works as expected for a few days, we can release the same change to SM customers:

  1. Create an MR in gitlab-zoekt. Example: !121
  2. Bump the Zoekt chart version in the main helm chart. Example: !4422. Note: MR is created automatically

Directories

Path Synopsis
cmd
gitlab-zoekt command
internal
api
authentication
Package authentication provides JWT token generation functionality.
Package authentication provides JWT token generation functionality.
callback
Package callback provides functionality for sending operation status callbacks to GitLab.
Package callback provides functionality for sending operation status callbacks to GitLab.
convert
Package convert provides utility functions for safe type conversions.
Package convert provides utility functions for safe type conversions.
gitaly
Package gitaly provides a client for interacting with GitLab's Gitaly service.
Package gitaly provides a client for interacting with GitLab's Gitaly service.
grpc/auth
Package auth provides gRPC interceptors for JWT authentication verification.
Package auth provides gRPC interceptors for JWT authentication verification.
index_path
Package indexpath provides utilities for managing index directory paths with support for the new zoekt_data subdirectory structure.
Package indexpath provides utilities for managing index directory paths with support for the new zoekt_data subdirectory structure.
indexer
Package indexer provides functionality for creating and managing code search indexes using the Zoekt search engine.
Package indexer provides functionality for creating and managing code search indexes using the Zoekt search engine.
middleware/auth
Package auth_middleware provides HTTP middleware for JWT authentication verification.
Package auth_middleware provides HTTP middleware for JWT authentication verification.
mode/indexer
Package indexer provides the main entry point and orchestration for the GitLab Zoekt indexer service.
Package indexer provides the main entry point and orchestration for the GitLab Zoekt indexer service.
mode/webserver
Package webserver implements a web server for the GitLab Zoekt code search service.
Package webserver implements a web server for the GitLab Zoekt code search service.
profiler
Package profiler provides functionality for integrating with Google Cloud Profiler.
Package profiler provides functionality for integrating with Google Cloud Profiler.
projectpath
Package projectpath provides a way to determine the root directory of the project at runtime.
Package projectpath provides a way to determine the root directory of the project at runtime.
search
Package search provides gRPC client functionality for distributed code search using Zoekt.
Package search provides gRPC client functionality for distributed code search using Zoekt.
secretreader
Package secretreader provides functionality for securely reading secret values from files.
Package secretreader provides functionality for securely reading secret values from files.
server
Package server implements a complete HTTP API server for the GitLab Zoekt indexer service.
Package server implements a complete HTTP API server for the GitLab Zoekt indexer service.
trace
Package trace provides OpenTracing integration for HTTP handlers.
Package trace provides OpenTracing integration for HTTP handlers.
zoekt
Package zoekt provides a client for interacting with the Zoekt code search indexing system.
Package zoekt provides a client for interacting with the Zoekt code search indexing system.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL