Keep user traversal_ids up to date in Elasticsearch
What does this MR do and why?
Listen for updates to traversal_ids and update user documents in Elasticsearch.
When traversal_ids
change for a namespace, we need to update Elasticsearch documents to ensure that the namespace_ancestry_ids
is correct.
This MR adds a callback when parent_id
changes on a Namespace
to enqueue a worker which does the processing.
For projects:
- Call
Elastic::ProcessBookkeepingService.track!
for users who are members of the project. This will recalculate thenamespace_ancestry_ids
entry for the project.
For groups:
- Call
Elastic::ProcessBookkeepingService.track!
for users who are members of the group or any of the group's descendants, because the descendants also need to be updated.
How to set up and validate locally
- Create a project
- Add a member to the project
- See that the member's
namespace_ancestry_ids
includes the new project e.g.curl http://localhost:9200/gitlab-development-users/_doc/user_1 | jq '._source'
- Transfer the project to another namespace
- See that the member's
namespace_ancestry_ids
has been updated to the new namespace - Create a group
- Add a member to the group
- See that the member's
namespace_ancestry_ids
includes the new group - Transfer the group to another namespace
- See that the member's
namespace_ancestry_ids
has been updated to the new namespace - Delete the group
- See that the member's
namespace_ancestry_ids
now doesn't include the group
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.
Related to #386558 (closed)
Edited by Madelein van Niekerk