Skip to content

Cache username to email

Carla Drago requested to merge 436320-cache-usernames into master

This change caches a map of GitHub user logins (known on GitLab as usernames) to the email address of the respective user.

This is done during the Collaborators import stage, and only if the :github_import_prioritize_collaborators feature flag is set to true (additional context: we need to import Collaborators before MRs and Issues in order to use the username/email map cache. We've put this behind a FF in order to roll-out the change gradually see: !142732 (merged))

The name of the module used to do the caching, recently moved from the BitBucket to Gitlab::Import namespace (!141793 (merged)), has been updated to something more descriptive and generic.

Screenshots

Three collaborators are imported, but only two have public emails

Screenshot_2024-03-05_at_17.18.45

redis redis/redis.socket> keys *github_import/project*

1) "cache:gitlab:github_import/project/985/source/username/carlad-gl"
2) "cache:gitlab:github_import/project/985/source/username/elephant199"

redis redis/redis.socket> get "cache:gitlab:github_import/project/985/source/username/carlad-gl"

"cdrago@gitlab.com"

redis redis/redis.socket> get "cache:gitlab:github_import/project/985/source/username/elephant199"

"carladrago+elephant@gmail.com"

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.

How to set up and validate locally

  1. checkout the branch and gdk restart
  2. in the gdk rails c console turn on the relevant feature flag Feature.enable(:github_import_prioritize_collaborators)
  3. on GitHub create or use an existing organization
  4. create or use an existing repository in this organization
  5. add at least two members to this repository, one with a public email, the other with a private email
  6. create or use a GitHub classic personal access token with read:org scope
  7. in the gdk UI, in the admin section, add two users with the same email addresses as the github users added above
  8. visit New Project > Import Project > GitHub Import and authenticate with the token
  9. make sure the import collaborators box is selected (it should be by default)
  10. go to the organization tab and select the repo from earlier and import it
  11. in the gdk redis-cli console select the 0 database: select 0 (this is the cache Gitlab::Cache::Import::Caching uses)
  12. search in the redis database for new keys that match *github_import/project*: keys *github_import/project*
  13. you should see keys for every github collaborator that has a public email address

Related to #436320 (closed)

Edited by Carla Drago

Merge request reports