How to handle errors caused by shallow clone in PostUploadPack
Follow-up from #184 (comment 31252810)
Shallow clone (git clone --depth=1 http://foo/bar.git
) uses three request-response cycles (GET, POST, POST) while normal cloning uses only two (GET, POST). There is a bug in the server side Git implementation of 'git clone' (git-upload-pack
) where it expects the third request to come on the same connection as the second request. Because of how we handle HTTP in GitLab, that never happens. The result is that the server side Git code returns a non-zero exit status after the second request/response cycle is done. This does not affect the client, which happily makes its three requests to get a shallow clone.
In workhorse we implemented a way to detect the second request out of the cycle, and when detected we ignore the exit code of git-upload-pack
. This detection is imperfect because it only scans the first 4kb of the request but it works most of the time.
Yesterday when we tried to route POST /git-upload-pack requests into Gitaly we saw a very high rate of non-zero exit statuses which Gitaly counted / reported as errors. We want to solve this by porting over the code from workhorse that detects the second request of a shallow clone.