Running git clone with a secondary geo node URL has LFS batch download redirected to primary
Summary
There is code to redirect git lfs push run on the secondary to the primary. It seems to be causing all batch operations, including downloads to be redirected. I believe the issue was introduced in commit aa73ef0a
Steps to reproduce
Create a fresh install with a git project with LFS. Set up a secondary geo node and replicate the project. Attempt to clone from the secondary with a recent version of git/lfs (I tried with 2.5.2). Watch the production log on the secondary. Notice it is redirecting to the primary.
Example Project
Any project with lfs files should show the issue (unless there is some limit below which it doesn't run clone as batch?).
What is the current bug behavior?
git clone and other git commands run against a secondary geo node and that cause non-write LFS batch operations end up with the lfs being redirected to the primary.
What is the expected correct behavior?
Read LFS operations should not be redirected.
Relevant logs and/or screenshots
from production log on secondary node when operation is run:
Started POST "/mygroup/myproject.git/info/lfs/objects/batch" for [clientip] at 2018-09-02 02:12:20 +0000
Processing by Projects::LfsApiController#batch as JSON
Parameters: {"operation"=>"download", "objects"=>[{"oid"=>"...
...
..."size"=>545}], "ref"=>{"name"=>"refs/heads/master"}}}
Redirected to https://primarynode.domain/mygroup/myproject.git/info/lfs/objects/batch
Filter chain halted as #<Proc:0x00007f3b5853d9b0@/opt/gitlab/embedded/service/gitlab-rails/ee/app/controllers/ee/projects/git_http_client_controller.rb:13> rendered or redirected
Completed 302 Found in 7ms (ActiveRecord: 1.0ms | Elasticsearch: 0.0ms)
Results of GitLab environment info
found on 11.2 omnibus ee reverted to 11.0 and bug was not present
Possible fixes
suspect problem introduced in aa73ef0a (i have no ruby xp nor have i looked at gitlab before, so i may be wrong here!)
i suspect the fix is to check for upload vs. download and only redirect on upload.