Browse Source

Merge "Optionally disable disk_limit_per_job"

tags/3.6.0
Zuul 2 months ago
parent
commit
967828b1f0
3 changed files with 22 additions and 1 deletions
  1. 1
    1
      doc/source/admin/components.rst
  2. 12
    0
      tests/unit/test_disk_accountant.py
  3. 9
    0
      zuul/executor/server.py

+ 1
- 1
doc/source/admin/components.rst View File

@@ -597,7 +597,7 @@ The following sections of ``zuul.conf`` are used by the executor:
597 597
       This integer is the maximum number of megabytes that any one job
598 598
       is allowed to consume on disk while it is running. If a job's
599 599
       scratch space has more than this much space consumed, it will be
600
-      aborted.
600
+      aborted. Set to -1 to disable the limit.
601 601
 
602 602
    .. attr:: trusted_ro_paths
603 603
 

+ 12
- 0
tests/unit/test_disk_accountant.py View File

@@ -65,6 +65,18 @@ class TestDiskAccountant(BaseTestCase):
65 65
             da.stop()
66 66
         self.assertFalse(da.thread.is_alive())
67 67
 
68
+    def test_disk_accountant_no_limit(self):
69
+        jobs_dir = tempfile.mkdtemp(
70
+            dir=os.environ.get("ZUUL_TEST_ROOT", None))
71
+        cache_dir = tempfile.mkdtemp()
72
+        executor_server = FakeExecutor()
73
+        da = DiskAccountant(jobs_dir, -1, executor_server.stopJobByJobDir,
74
+                            cache_dir)
75
+        da.start()
76
+        self.assertFalse(da.running)
77
+        da.stop()
78
+        self.assertFalse(da.running)
79
+
68 80
     def test_cache_hard_links(self):
69 81
         root_dir = tempfile.mkdtemp(
70 82
             dir=os.environ.get("ZUUL_TEST_ROOT", None))

+ 9
- 0
zuul/executor/server.py View File

@@ -149,16 +149,25 @@ class DiskAccountant(object):
149 149
             self.stop_event.wait(delay_time)
150 150
 
151 151
     def start(self):
152
+        if self.limit < 0:
153
+            # No need to start if there is no limit.
154
+            return
152 155
         self._running = True
153 156
         self.thread.start()
154 157
 
155 158
     def stop(self):
159
+        if not self.running:
160
+            return
156 161
         self._running = False
157 162
         self.stop_event.set()
158 163
         # We join here to avoid whitelisting the thread -- if it takes more
159 164
         # than 5s to stop in tests, there's a problem.
160 165
         self.thread.join(timeout=5)
161 166
 
167
+    @property
168
+    def running(self):
169
+        return self._running
170
+
162 171
 
163 172
 class Watchdog(object):
164 173
     def __init__(self, timeout, function, args):

Loading…
Cancel
Save