Browse Source

Make git clone timeout configurable

When dealing with large repos or slow connections to the scm the
default clone timeout of 5 minutes may not be sufficient. Thus a
configurable clone/fetch timeout can make it possible to handle those
repos.

Change-Id: I0711895806b7cbcc8b9fa3ba085bcf79d7fb6665
tags/3.6.0
Tobias Henkel 5 months ago
parent
commit
e69c9fe97b
No account linked to committer's email address

+ 10
- 0
doc/source/admin/components.rst View File

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

+ 1
- 1
zuul/configloader.py View File

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

+ 2
- 1
zuul/executor/server.py View File

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

+ 2
- 0
zuul/merger/client.py View File

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

+ 4
- 2
zuul/merger/merger.py View File

@@ -496,7 +496,7 @@ class Repo(object):
496 496
 class Merger(object):
497 497
     def __init__(self, working_root, connections, email, username,
498 498
                  speed_limit, speed_time, cache_root=None, logger=None,
499
-                 execution_context=False):
499
+                 execution_context=False, git_timeout=300):
500 500
         self.logger = logger
501 501
         if logger is None:
502 502
             self.log = logging.getLogger("zuul.Merger")
@@ -510,6 +510,7 @@ class Merger(object):
510 510
         self.username = username
511 511
         self.speed_limit = speed_limit
512 512
         self.speed_time = speed_time
513
+        self.git_timeout = git_timeout
513 514
         self.cache_root = cache_root
514 515
         # Flag to determine if the merger is used for preparing repositories
515 516
         # for job execution. This flag can be used to enable executor specific
@@ -528,7 +529,8 @@ class Merger(object):
528 529
                 cache_path = None
529 530
             repo = Repo(
530 531
                 url, path, self.email, self.username, self.speed_limit,
531
-                self.speed_time, sshkey, cache_path, self.logger)
532
+                self.speed_time, sshkey=sshkey, cache_path=cache_path,
533
+                logger=self.logger, git_timeout=self.git_timeout)
532 534
 
533 535
             self.repos[key] = repo
534 536
         except Exception:

+ 2
- 1
zuul/merger/server.py View File

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

Loading…
Cancel
Save