Commit 31fb547f authored by Yorick Peterse's avatar Yorick Peterse

Backport Gitaly dynamic timeouts from EE

EE added the ability to set timeouts when handling blobs. Since there's
no particular reason for this to be EE specific we can just backport
this to CE.
parent 5d654a22
...@@ -344,12 +344,12 @@ module Gitlab ...@@ -344,12 +344,12 @@ module Gitlab
end end
end end
def new_blobs(newrev) def new_blobs(newrev, dynamic_timeout: nil)
return [] if newrev.blank? || newrev == ::Gitlab::Git::BLANK_SHA return [] if newrev.blank? || newrev == ::Gitlab::Git::BLANK_SHA
strong_memoize("new_blobs_#{newrev}") do strong_memoize("new_blobs_#{newrev}") do
wrapped_gitaly_errors do wrapped_gitaly_errors do
gitaly_ref_client.list_new_blobs(newrev, REV_LIST_COMMIT_LIMIT) gitaly_ref_client.list_new_blobs(newrev, REV_LIST_COMMIT_LIMIT, dynamic_timeout: dynamic_timeout)
end end
end end
end end
......
...@@ -84,15 +84,22 @@ module Gitlab ...@@ -84,15 +84,22 @@ module Gitlab
commits commits
end end
def list_new_blobs(newrev, limit = 0) def list_new_blobs(newrev, limit = 0, dynamic_timeout: nil)
request = Gitaly::ListNewBlobsRequest.new( request = Gitaly::ListNewBlobsRequest.new(
repository: @gitaly_repo, repository: @gitaly_repo,
commit_id: newrev, commit_id: newrev,
limit: limit limit: limit
) )
timeout =
if dynamic_timeout
[dynamic_timeout, GitalyClient.medium_timeout].min
else
GitalyClient.medium_timeout
end
response = GitalyClient response = GitalyClient
.call(@storage, :ref_service, :list_new_blobs, request, timeout: GitalyClient.medium_timeout) .call(@storage, :ref_service, :list_new_blobs, request, timeout: timeout)
response.flat_map do |msg| response.flat_map do |msg|
# Returns an Array of Gitaly::NewBlobObject objects # Returns an Array of Gitaly::NewBlobObject objects
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment