Fix for determining write index
What does this MR do and why?
Related to #428070 (closed)
Found while working on implementing indexing all projects in: !134456 (merged)
This was causing spec failures when trying to get a document count from Elasticsearch for a specific index.
- refactors logic which determines which index is the write index
- adds a spec for the method changed
Screenshots or screen recordings
N/A - backend change only
How to set up and validate locally
- setup gdk for elasticsearch
- checkout
master
branch - create 2 test indexes, using the same alias, with one set to the write index
curl --request PUT \
--url http://localhost:9200/test-index-2 \
--header 'Content-Type: application/json' \
--data '{
"aliases": {
"test_alias": {
"is_write_index": false
}
}
}'
curl --request PUT \
--url http://localhost:9200/test-index-1 \
--header 'Content-Type: application/json' \
--data '{
"aliases": {
"test_alias": {
"is_write_index": true
}
}
}'
- in rails console, run the method to find each index. only one should be the write index <-- this is the bug
> elastic_helper = Gitlab::Elastic::Helper.default
> elastic_helper.target_index_names(target: 'test_alias')
=> {"test-index-1"=>true, "test-index-2"=>true}
- checkout this (
428070-fix-for-determining-write-index
) branch - run the same method in rails console
> elastic_helper = Gitlab::Elastic::Helper.default
> elastic_helper.target_index_names(target: 'test_alias')
=> {"test-index-1"=>true, "test-index-2"=>false}
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