Fix queue Elasticsearch indexing when branch changes for repo

What does this MR do and why?

Related to #390341 (closed)

Create a new gitlab event store message emitted when default branch changes for a repository. This is to avoid having to add code to the PostReceiveWorker where current commit changes are queued for indexing.

  • Create a new event for when a repository default branch has been changed.
  • Create a new worker to subscribe to the event if Elasticsearch indexing is enabled
  • Handle the event for repository containers that support indexing: Project, GroupWiki, and ProjectWiki. Note: Snippets do have repositories but only titles and descriptions are indexed (not any repository data)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Pre-setup

  1. Setup elasticsearch for gdk and index everything
  2. ensure that zoekt code search is disabled if you've previously had it enabled image

Project repository

  1. Create a new project (or use an existing project) that has files added
  2. Create a new branch new-default-branch for that project, commit an additional file (I used TEST.md) to it that does not exist in the current default branch
  3. Change the default branch to new-default-branch for that project under Project Settings - Repository Settings image
  4. Perform a search for TEST.md and verify that the new branch has been indexed and the new file is searchable image

Project wiki & group repository

note: I'm not 100% confident this kicks off a branch changed event. I wasn't able to find great instructions on how to change the default wiki branch but this should cover the case nonetheless

  1. Create a new project or group (or use an existing one) that has wiki enabled
  2. Add a wiki
  3. Clone the wiki repository locally
  4. Create a new branch new-default-branch for the wiki locally, commit a change to the existing wiki file (do not push up yet)
  5. Delete the project or group wiki in rails console
  6. Push the new branch up (it should become the default wiki branch): git push --set-upstream origin new-default-branch
  7. Search for the new text you added in the project or group wiki and it should come back image

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

Loading