From f6a8c61f15deb7906d2caae10fea702235123954 Mon Sep 17 00:00:00 2001 From: Peter Mikus Date: Mon, 7 Oct 2019 13:37:06 +0000 Subject: FIX: LXC tmpfs mount - Should fix the read/write to socket for LXC Signed-off-by: Peter Mikus Change-Id: I56a84145cf2fb95742423789681ca2e24ddf0c98 --- resources/libraries/python/ContainerUtils.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'resources/libraries/python') diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py index ae820b306b..b02033eeb9 100644 --- a/resources/libraries/python/ContainerUtils.py +++ b/resources/libraries/python/ContainerUtils.py @@ -633,11 +633,18 @@ class LXC(ContainerEngine): :raises RuntimeError: If creating the container fails. """ if self.container.mnt: + # LXC fix for tmpfs + # https://github.com/lxc/lxc/issues/434 + ret, _, _ = self.container.ssh.exec_command_sudo( + "sh -c 'echo \"{e}\" >> /var/lib/lxc/{c.name}/config'". + format(e="lxc.mount.entry = tmpfs run tmpfs defaults", + c=self.container)) + if int(ret) != 0: + raise RuntimeError('Failed to write {c.name} config.'. + format(c=self.container)) + for mount in self.container.mnt: host_dir, guest_dir = mount.split(':') - if host_dir.endswith('/'): - self.container.ssh.exec_command_sudo( - "sh -c 'mkdir -p {host_dir}'".format(host_dir=host_dir)) options = 'bind,create=dir' \ if guest_dir.endswith('/') else 'bind,create=file' entry = 'lxc.mount.entry = {host_dir} {guest_dir} none ' \ @@ -656,8 +663,7 @@ class LXC(ContainerEngine): if self.container.cpuset_cpus else '' ret, _, _ = self.container.ssh.exec_command_sudo( - 'lxc-start --name {c.name} --daemon'. - format(c=self.container)) + 'lxc-start --name {c.name} --daemon'.format(c=self.container)) if int(ret) != 0: raise RuntimeError('Failed to start container {c.name}.'. format(c=self.container)) -- cgit 1.2.3-korg