Let a user be canaried through gitway with its own flag
What does this MR do and why?
route_gitaly_through_gitway's actor is the storage, which ChatOps can't name. So --user and --project gates are stored but never match, and the only way to try gitway in production today is a percentage of every storage's traffic. I found this enabling it for --project=jcaigitlab/gitway in gprd: the gate was set and gitway-gprd served zero RPCs.
This adds a route_gitaly_through_gitway_for_user ops flag, checked with Feature.enabled? against the current request's user, which Feature::Gitaly.user_actor reads from the application context. It's checked before the storage flag, and like it only on storages with a gitway_address, so nothing changes elsewhere. That context also holds while Rails hands an address to Workhorse and gitlab-shell, and in Sidekiq jobs enqueued on the user's behalf, so all of that user's Gitaly traffic goes through gitway, including the connection_data those jobs hand to the Elasticsearch and Duo Code indexers.
A couple of notes for review:
- It's a separate flag so percentages stay on
route_gitaly_through_gitwayand are only rolled once per call. Only user gates are set on the new one. - Project gates are deliberately left out. The context only carries the project's path, so supporting them would cost a
find_by_full_pathon every request in the fleet, not just that project's, while any project gate was set. A user gate is enough to canary before we go to a percentage.
Once this is deployed:
/chatops gitlab run feature set route_gitaly_through_gitway_for_user true --user=jcaigitlabReferences
- Rollout issue: #632192
- Feature issue: #632171 (closed)
- Introduced the storage flag: !259697 (merged)
How to set up and validate locally
- Give a storage a
gitway_addressingitlab.yml. - In a Rails console,
Feature.enable(:route_gitaly_through_gitway_for_user, User.find_by_username('root')). - As root, browse a repository on that storage: its Gitaly calls go to the
gitway_address. As another user, they go to thegitaly_address.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.