Bug 1391476 - Tell run-task about volumes so it can sanitize them; r=dustin

We recently introduced support for telling run-task about caches so
it could sanitize them automatically. We also recently taught
docker-worker and docker-engine how to declare volumes.

Building on that work, we now pass a list of paths corresponding
to Docker volumes to run-task.

run-task now verifies volumes behave as expected. Unless the volume
paths correspond to caches, run-task verifies they are empty and chowns
them to an appropriate owner.

Requiring empty volumes is an arbitrary decision. But as the inline
comment says, it keeps things simpler and makes caches and volumes
behave more like each other.

MozReview-Commit-ID: 5lm2uIitrS3
This commit is contained in:
Gregory Szorc
2017-08-23 10:47:37 -07:00
parent 13fbc64bc2
commit 6be419bf57
2 changed files with 57 additions and 2 deletions

View File

@@ -698,6 +698,8 @@ def build_docker_worker_payload(config, task, task_def):
}
payload['artifacts'] = artifacts
run_task = payload.get('command', [''])[0].endswith('run-task')
if 'caches' in worker:
caches = {}
@@ -709,8 +711,6 @@ def build_docker_worker_payload(config, task, task_def):
# This means run-task can make changes to cache interaction at any time
# without regards for backwards or future compatibility.
run_task = payload.get('command', [''])[0].endswith('run-task')
if run_task:
suffix = '-%s' % _run_task_suffix()
else:
@@ -735,6 +735,11 @@ def build_docker_worker_payload(config, task, task_def):
payload['cache'] = caches
# And send down volumes information to run-task as well.
if run_task and worker.get('volumes'):
payload['env']['TASKCLUSTER_VOLUMES'] = ';'.join(
sorted(worker['volumes']))
if features:
payload['features'] = features
if capabilities: