Skip to content

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 the namespace_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

  1. Create a project
  2. Add a member to the project
  3. 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'
  4. Transfer the project to another namespace
  5. See that the member's namespace_ancestry_ids has been updated to the new namespace
  6. Create a group
  7. Add a member to the group
  8. See that the member's namespace_ancestry_ids includes the new group
  9. Transfer the group to another namespace
  10. See that the member's namespace_ancestry_ids has been updated to the new namespace
  11. Delete the group
  12. 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.

Related to #386558 (closed)

Edited by Madelein van Niekerk

Merge request reports

Loading