Index work items when project visibility level changes
What does this MR do and why?
Found while working on !170853 (merged)
This MR has a few related changes in it:
- fixes a bug where project visibility changes are not updating the project's indexed work items for Advanced search.
- does not index
namespace_visibility_levelfor project level work items. This field is not used to query project level work items (theproject_level_visibilityfield is). Additionally, this field is not updated when the namespace visibility level is changed for project level work items. Group associations are updated by a worker which callsgroup.work_itemsin batches. Since project level work items are not associated with a group (they are associated with a project namespace), they do not get updated by the worker. I think it's ok to not fill this field out
Note: The indexed work item data may be out of sync with the database. I've opened a follow up MR to reindex all work items that will be merged after this one. I want to keep them separate so I can backport this fix, we usually do not backport migrations
References
Please include cross links to any resources that are relevant to this MR This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
N/A
How to set up and validate locally
- Enable elasticseacch for gdk
- Create a few work items in a public project, I used project id 7 (they must be issues/work items, not epic work items)
- (query below) query elasticsearch directly to see the data, pay attention to the
project_visibility_levelfield - Update the project visibility level to private
- query elasticsearch directly to see the data, verify the
project_visibility_levelfield was updated
curl --request POST \
--url http://localhost:9200/gitlab-development-work_items/_search \
--header 'Content-Type: application/json' \
--data '{
"size": 30,
"query": {
"term": {
"project_id": 7
}
}
}'
Edited by Terri Chu