Tiago Gomes pushed to branch tiagogomes/issue-520 at BuildStream / buildstream
Commits:
-
289de2ef
by Adam Jones at 2018-08-07T09:24:58Z
-
e42325b9
by Javier Jardón at 2018-08-07T10:29:46Z
-
7e939e3c
by Tiago Gomes at 2018-08-07T10:36:20Z
-
4fece773
by Tiago Gomes at 2018-08-07T10:36:20Z
5 changed files:
- buildstream/_artifactcache/artifactcache.py
- buildstream/_scheduler/jobs/elementjob.py
- buildstream/_scheduler/queues/buildqueue.py
- buildstream/_scheduler/queues/queue.py
- doc/source/install_artifacts.rst
Changes:
... | ... | @@ -276,11 +276,6 @@ class ArtifactCache(): |
276 | 276 |
# (int) An approximation of the artifact cache size.
|
277 | 277 |
#
|
278 | 278 |
def get_approximate_cache_size(self):
|
279 |
- # If we don't currently have an estimate, figure out the real
|
|
280 |
- # cache size.
|
|
281 |
- if self.estimated_size is None:
|
|
282 |
- self.estimated_size = self.calculate_cache_size()
|
|
283 |
- |
|
284 | 279 |
return self.estimated_size
|
285 | 280 |
|
286 | 281 |
################################################
|
... | ... | @@ -534,10 +529,8 @@ class ArtifactCache(): |
534 | 529 |
# ArtifactCache.estimated_size.
|
535 | 530 |
#
|
536 | 531 |
def _add_artifact_size(self, artifact_size):
|
537 |
- if not self.estimated_size:
|
|
538 |
- self.estimated_size = self.calculate_cache_size()
|
|
539 |
- |
|
540 |
- self.estimated_size += artifact_size
|
|
532 |
+ if self.estimated_size:
|
|
533 |
+ self.estimated_size += artifact_size
|
|
541 | 534 |
|
542 | 535 |
# _set_cache_size()
|
543 | 536 |
#
|
... | ... | @@ -109,13 +109,11 @@ class ElementJob(Job): |
109 | 109 |
data = {}
|
110 | 110 |
|
111 | 111 |
workspace = self._element._get_workspace()
|
112 |
- artifact_size = self._element._get_artifact_size()
|
|
113 |
- cache_size = self._element._get_artifact_cache().calculate_cache_size()
|
|
114 |
- |
|
115 | 112 |
if workspace is not None:
|
116 | 113 |
data['workspace'] = workspace.to_dict()
|
114 |
+ |
|
115 |
+ artifact_size = self._element._get_artifact_size()
|
|
117 | 116 |
if artifact_size is not None:
|
118 | 117 |
data['artifact_size'] = artifact_size
|
119 |
- data['cache_size'] = cache_size
|
|
120 | 118 |
|
121 | 119 |
return data
|
1 | 1 |
#
|
2 |
-# Copyright (C) 2016 Codethink Limited
|
|
2 |
+# Copyright (C) 2018 Codethink Limited
|
|
3 | 3 |
#
|
4 | 4 |
# This program is free software; you can redistribute it and/or
|
5 | 5 |
# modify it under the terms of the GNU Lesser General Public
|
... | ... | @@ -92,13 +92,16 @@ class BuildQueue(Queue): |
92 | 92 |
return
|
93 | 93 |
|
94 | 94 |
artifact_size = job.child_data.get('artifact_size', False)
|
95 |
+ if not artifact_size:
|
|
96 |
+ return
|
|
95 | 97 |
|
96 |
- if artifact_size:
|
|
97 |
- cache = element._get_artifact_cache()
|
|
98 |
- cache._add_artifact_size(artifact_size)
|
|
98 |
+ cache = element._get_artifact_cache()
|
|
99 |
+ cache._add_artifact_size(artifact_size)
|
|
99 | 100 |
|
100 |
- if cache.get_approximate_cache_size() > self._scheduler.context.cache_quota:
|
|
101 |
- self._scheduler._check_cache_size_real()
|
|
101 |
+ approx_size = cache.get_approximate_cache_size()
|
|
102 |
+ if not approx_size or (approx_size >
|
|
103 |
+ self._scheduler.context.cache_quota):
|
|
104 |
+ self._scheduler._check_cache_size_real()
|
|
102 | 105 |
|
103 | 106 |
def done(self, job, element, result, success):
|
104 | 107 |
|
... | ... | @@ -301,8 +301,6 @@ class Queue(): |
301 | 301 |
# Update values that need to be synchronized in the main task
|
302 | 302 |
# before calling any queue implementation
|
303 | 303 |
self._update_workspaces(element, job)
|
304 |
- if job.child_data:
|
|
305 |
- element._get_artifact_cache().cache_size = job.child_data.get('cache_size')
|
|
306 | 304 |
|
307 | 305 |
# Give the result of the job to the Queue implementor,
|
308 | 306 |
# and determine if it should be considered as processed
|
... | ... | @@ -143,6 +143,50 @@ Instance with push and requiring client authentication: |
143 | 143 |
|
144 | 144 |
bst-artifact-server --port 11002 --server-key server.key --server-cert server.crt --client-certs authorized.crt --enable-push /home/artifacts/artifacts
|
145 | 145 |
|
146 |
+Managing the cache with systemd
|
|
147 |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
148 |
+ |
|
149 |
+It is better to run the cache as a systemd service, especially if it is running on a dedicated server, as this will allow systemd to manage the cache, incase the server ever encounters any issues.
|
|
150 |
+ |
|
151 |
+Below are two examples of how to run the cache server as a systemd service, one is for pull only and the other is configured for push & pull.
|
|
152 |
+ |
|
153 |
+.. code:: ini
|
|
154 |
+ |
|
155 |
+ #
|
|
156 |
+ # Pull
|
|
157 |
+ #
|
|
158 |
+ [Unit]
|
|
159 |
+ Description=Buildstream Artifact pull server
|
|
160 |
+ After=remote-fs.target network-online.target
|
|
161 |
+ |
|
162 |
+ [Service]
|
|
163 |
+ Environment="LC_ALL=C.UTF-8"
|
|
164 |
+ ExecStart=/usr/local/bin/bst-artifact-server --port 11001 --server-key {{certs_path}}/privkey.pem --
|
|
165 |
+ server-cert {{certs_path}}/fullchain.pem {{artifacts_path}}
|
|
166 |
+ User=artifacts
|
|
167 |
+ |
|
168 |
+ [Install]
|
|
169 |
+ WantedBy=multi-user.target
|
|
170 |
+ |
|
171 |
+ |
|
172 |
+ #
|
|
173 |
+ # Pull/Push
|
|
174 |
+ #
|
|
175 |
+ [Unit]
|
|
176 |
+ Description=Buildstream Artifact pull/push server
|
|
177 |
+ After=remote-fs.target network-online.target
|
|
178 |
+ |
|
179 |
+ [Service]
|
|
180 |
+ Environment="LC_ALL=C.UTF-8"
|
|
181 |
+ ExecStart=/usr/local/bin/bst-artifact-server --port 11002 --server-key {{certs_path}}/privkey.pem --
|
|
182 |
+ server-cert {{certs_path}}/fullchain.pem --client-certs /home/artifacts/authorized.crt --enable-push /
|
|
183 |
+ {{artifacts_path}}
|
|
184 |
+ User=artifacts
|
|
185 |
+ |
|
186 |
+ [Install]
|
|
187 |
+ WantedBy=multi-user.target
|
|
188 |
+ |
|
189 |
+Here we define when systemd should start the service, which is after the networking stack has been started, we then define how to run the cache with the desired configuration, under the artifacts user. The {{ }} are there to denote where you should change these files to point to your desired locations.
|
|
146 | 190 |
|
147 | 191 |
User configuration
|
148 | 192 |
~~~~~~~~~~~~~~~~~~
|