Remove container routing in remove_wikis_from_the_standalone_index
Summary
Sometimes we need to call the ElasticDeleteProjectWorker
from the workers like ElasticWikiIndexerWorker
for the case when the container is not using elasticsearch. This call will try to remove all the wikis of this container by calling remove_wikis_from_the_standalone_index
. But inside this method, it is using the routing
option with the value "n_#{container.root_ancestor.id}"
. Now the problem is since this container is not using elasticsearch, means the routing for these wikis might be very old(transfer of containers from one namespace to another) which results in mismatching with the current "n_#{container.root_ancestor.id}"
Steps to reproduce
- Select a namespace with project.
- Create some wikis inside this project.
- Ensure on Elasticsearch that wiki documents exist
- Remove this namespace from the elastic_indexed_namespaces list
- Now move the project to a different namespace
- Now run the following command in the rails console. Replace
project_id
with the one you have chosen at the first step.
ElasticWikiIndexerWorker.new.perform(project_id, 'Project', force: true)
- Check on Elastic that the documents are not removed.
What is the current bug behavior?
Cleaning up of wikis is considering routing which may be stale and because of that cleaning up does not work properly.
What is the expected correct behavior?
Cleaning up of wikis should not consider routing
Relevant logs and/or screenshots
Possible fixes
Remove the elsif
condition here: https://gitlab.com/gitlab-org/gitlab/-/blob/b31b85c1862393d5413312124e58b52307c94823/ee/lib/gitlab/elastic/helper.rb#L439