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, andProjectWiki. 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
- Setup elasticsearch for gdk and index everything
- ensure that zoekt code search is disabled if you've previously had it enabled
Project repository
- Create a new project (or use an existing project) that has files added
- Create a new branch
new-default-branchfor that project, commit an additional file (I usedTEST.md) to it that does not exist in the current default branch - Change the default branch to
new-default-branchfor that project under Project Settings - Repository Settings
- Perform a search for
TEST.mdand verify that the new branch has been indexed and the new file is searchable
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
- Create a new project or group (or use an existing one) that has wiki enabled
- Add a wiki
- Clone the wiki repository locally
- Create a new branch
new-default-branchfor the wiki locally, commit a change to the existing wiki file (do not push up yet) - Delete the project or group wiki in rails console
- Push the new branch up (it should become the default wiki branch):
git push --set-upstream origin new-default-branch - Search for the new text you added in the project or group wiki and it should come back
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Terri Chu



