summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rwxr-xr-xworker_manager32
2 files changed, 34 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 252b256..d6f3d77 100644
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,9 @@ Version 0.23+git, not yet released
parameter. The old behaviour of having the suite name as an argument
to the `debootstrap` field in the action still works.
+* When an action is run in a chroot, the `/proc` and `/sys`
+ filesystems get bind mounted temporarily into the chroot.
+
Version 0.23, released 2018-01-22
----------------------------------
diff --git a/worker_manager b/worker_manager
index 81015c2..e2cbc32 100755
--- a/worker_manager
+++ b/worker_manager
@@ -374,6 +374,30 @@ class Runner:
self._post(stream, buf)
+class Mounter:
+
+ def __init__(self, mounts, runner):
+ self._mounts = mounts
+ self._runner = runner
+
+ def __enter__(self):
+ self.mount()
+ return self
+
+ def __exit__(self, *args):
+ self.unmount()
+
+ def mount(self):
+ for dirname, mp in self._mounts:
+ if not os.path.exists(mp):
+ os.mkdir(mp)
+ self._runner.runcmd(['sudo', 'mount', '--bind', dirname, mp])
+
+ def unmount(self):
+ for dirname, mp in reversed(self._mounts):
+ self._runner.runcmd(['sudo', 'umount', mp])
+
+
class WorkerBase:
def __init__(self, api, workspace, systree, post):
@@ -386,9 +410,14 @@ class WorkerBase:
params = work.get('parameters', {})
params_text = self.params64(params)
argv = self.get_argv(work, params_text)
+ mounts = []
if self.where(work) == 'chroot':
logging.debug('CHROOT REQUESTED')
argv = ['sudo', 'chroot', self._workspace] + argv
+ mounts = [
+ ('/proc', os.path.join(self._workspace, 'proc')),
+ ('/sys', os.path.join(self._workspace, 'sys')),
+ ]
elif self.where(work) == 'container':
logging.debug('CONTAINER REQUESTED')
bind = '{}:/workspace'.format(self._workspace)
@@ -402,7 +431,8 @@ class WorkerBase:
else:
logging.debug('HOST REQUESTED')
runner = Runner(self._post)
- return runner.runcmd(argv, cwd=self._workspace)
+ with Mounter(mounts, runner):
+ return runner.runcmd(argv, cwd=self._workspace)
def params64(self, params):
as_json = json.dumps(params)