Zoekt: [Rails] Allow indexing projects without a repository
## Background Currently, we have two issues with indexing non-existing and empty repositories: - `empty_repo?` check that blows up when used with non-existing repositories - [`gitaly_payload`](https://gitlab.com/gitlab-org/gitlab/-/blob/45ec779e899d3db0e41e666969ed73687464ea83/ee/app/services/search/zoekt/task_serializer_service.rb#L103) that blows up when used with such a repository ## Proposal We should: 1. Replace `project.empty_repo?` with `!project.repo_exists?` 2. Allow returning empty gitaly connection info if there's no repository, or it's empty (`!project.repo_exists?`) to fix the existing exceptions (please guard this via `::Search::Zoekt.skip_empty_repositories?` or another FF) to ensure that we update the indexer before enabling the FF 3. Send a flag `"NoOp": true` as part of the `index_repo_payload` <details><summary>Click to expand</summary> Potential diff: ```diff diff --git i/ee/app/services/search/zoekt/indexing_task_service.rb w/ee/app/services/search/zoekt/indexing_task_service.rb index fcef625db549..756cc7ff9140 100644 --- i/ee/app/services/search/zoekt/indexing_task_service.rb +++ w/ee/app/services/search/zoekt/indexing_task_service.rb @@ -57,7 +57,7 @@ def logger def preflight_check? return true if task_type == :delete_repo return false unless project - return false if ::Search::Zoekt.skip_empty_repositories? && project.empty_repo? + return false if ::Search::Zoekt.skip_empty_repositories? && !project.repo_exists? true end diff --git i/ee/app/services/search/zoekt/task_serializer_service.rb w/ee/app/services/search/zoekt/task_serializer_service.rb index 957d62f57311..41356955f142 100644 --- i/ee/app/services/search/zoekt/task_serializer_service.rb +++ w/ee/app/services/search/zoekt/task_serializer_service.rb @@ -101,6 +101,8 @@ def delete_graph_repo_payload end def gitaly_payload(project) + return {} unless project.repo_exists? + repository_storage = project.repository_storage connection_info = Gitlab::GitalyClient.connection_data(repository_storage) repository_path = "#{project.repository.disk_path}.git" ``` </details> > [!note] > We might have other `empty_repo?` checks in the Zoekt codebase. Ideally, we should replace these as well <!-- Use this section to explain the feature and how it will work. It can be helpful to add technical details, design proposals, and links to related epics or issues. --> <!-- Please add a label for the type of maintenance as per https://handbook.gitlab.com/handbook/product/groups/product-analysis/engineering/metrics/#work-type-classification -->
issue