Don't match /info/refs.json as a Git HTTP client
What does this MR do?
This change narrows down which HTTP requests get treated Git HTTP clients by GitLab.
Are there points in the code the reviewer needs to double check?
Why was this MR needed?
We noticed that we were spending relatively much CPU time on 'GET
/info/refs.jon' requests in Projects::GitHttpController#info_refs.
That controller does not implement any sort of .json
response so we
can fail these requests in the router instead.
This seems to be faster at least in development.
Before:
Started GET "/root/gitlab-test.git/info/refs.json" for 127.0.0.1 at 2017-06-08 16:29:42 +0200
[1m[36mActiveRecord::SchemaMigration Load (0.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
Processing by Projects::GitHttpController#info_refs as JSON
Parameters: {"namespace_id"=>"root", "project_id"=>"gitlab-test.git"}
[1m[35mProject Load (2.2ms)[0m SELECT "projects".* FROM "projects" INNER JOIN "routes" ON "routes"."source_id" = "projects"."id" AND "routes"."source_type" = $1 WHERE "projects"."pending_delete" = $2 AND ((LOWER(routes.path) = LOWER('root/gitlab-test'))) ORDER BY (CASE WHEN routes.path = 'root/gitlab-test' THEN 0 ELSE 1 END) LIMIT 1 [["source_type", "Project"], ["pending_delete", "f"]]
Rendered text template (0.0ms)
Filter chain halted as :authenticate_user rendered or redirected
Completed 401 Unauthorized in 4450ms (Views: 8.1ms | ActiveRecord: 4.0ms)
After:
Started GET "/root/gitlab-test.git/info/refs.json" for 127.0.0.1 at 2017-06-08 16:30:59 +0200
Processing by ApplicationController#route_not_found as JSON
Parameters: {"unmatched_route"=>"root/gitlab-test.git/info/refs"}
Completed 401 Unauthorized in 2ms (ActiveRecord: 0.0ms)
Screenshots (if relevant)
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
API support added - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together