Merge "Make git clone timeout configurable"

This commit is contained in:
Zuul 2019-02-04 16:33:46 +00:00 committed by Gerrit Code Review
commit 86d6a46bea
6 changed files with 21 additions and 5 deletions

View File

@ -373,6 +373,16 @@ The following section of ``zuul.conf`` is used by the merger:
Value in seconds, setting to 0 will disable.
.. attr:: git_timeout
:default: 300
Timeout for git clone and fetch operations. This can be useful when
dealing with large repos. Note that large timeouts can increase startup
and reconfiguration times if repos are not cached so be cautious when
increasing this value.
Value in seconds.
.. attr:: git_user_email
Value to pass to `git config user.email

View File

@ -1587,7 +1587,7 @@ class TenantParser(object):
for job in jobs:
self.log.debug("Waiting for cat job %s" % (job,))
job.wait()
job.wait(self.merger.git_timeout)
if not job.updated:
raise Exception("Cat job %s failed" % (job,))
self.log.debug("Cat job %s got files %s" %

View File

@ -2152,6 +2152,7 @@ class ExecutorServer(object):
config, 'merger', 'git_http_low_speed_limit', '1000')
self.merge_speed_time = get_default(
config, 'merger', 'git_http_low_speed_time', '30')
self.git_timeout = get_default(config, 'merger', 'git_timeout', 300)
# If the execution driver ever becomes configurable again,
# this is where it would happen.
execution_wrapper_name = 'bubblewrap'
@ -2228,7 +2229,7 @@ class ExecutorServer(object):
return zuul.merger.merger.Merger(
root, self.connections, self.merge_email, self.merge_name,
self.merge_speed_limit, self.merge_speed_time, cache_root, logger,
execution_context=True)
execution_context=True, git_timeout=self.git_timeout)
def start(self):
self._running = True

View File

@ -85,6 +85,8 @@ class MergeClient(object):
self.gearman.addServer(server, port, ssl_key, ssl_cert, ssl_ca,
keepalive=True, tcp_keepidle=60,
tcp_keepintvl=30, tcp_keepcnt=5)
self.git_timeout = get_default(
self.config, 'merger', 'git_timeout', 300)
self.log.debug("Waiting for gearman")
self.gearman.waitForServer()
self.jobs = set()

View File

@ -496,7 +496,7 @@ class Repo(object):
class Merger(object):
def __init__(self, working_root, connections, email, username,
speed_limit, speed_time, cache_root=None, logger=None,
execution_context=False):
execution_context=False, git_timeout=300):
self.logger = logger
if logger is None:
self.log = logging.getLogger("zuul.Merger")
@ -510,6 +510,7 @@ class Merger(object):
self.username = username
self.speed_limit = speed_limit
self.speed_time = speed_time
self.git_timeout = git_timeout
self.cache_root = cache_root
# Flag to determine if the merger is used for preparing repositories
# for job execution. This flag can be used to enable executor specific
@ -528,7 +529,8 @@ class Merger(object):
cache_path = None
repo = Repo(
url, path, self.email, self.username, self.speed_limit,
self.speed_time, sshkey, cache_path, self.logger)
self.speed_time, sshkey=sshkey, cache_path=cache_path,
logger=self.logger, git_timeout=self.git_timeout)
self.repos[key] = repo
except Exception:

View File

@ -41,9 +41,10 @@ class MergeServer(object):
config, 'merger', 'git_http_low_speed_limit', '1000')
speed_time = get_default(
config, 'merger', 'git_http_low_speed_time', '30')
git_timeout = get_default(config, 'merger', 'git_timeout', 300)
self.merger = merger.Merger(
merge_root, connections, merge_email, merge_name, speed_limit,
speed_time)
speed_time, git_timeout=git_timeout)
self.command_map = dict(
stop=self.stop)
command_socket = get_default(