diff options
author | Peter Mikus <pmikus@cisco.com> | 2019-10-07 13:37:06 +0000 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2019-10-07 14:21:54 +0000 |
commit | f6a8c61f15deb7906d2caae10fea702235123954 (patch) | |
tree | a3c702d1a0267be0379e12bae285af3e83f22c2f /resources | |
parent | fdd4211559f1be8cf7e82ab429ebc5c7de70946b (diff) |
FIX: LXC tmpfs mount
- Should fix the read/write to socket for LXC
Signed-off-by: Peter Mikus <pmikus@cisco.com>
Change-Id: I56a84145cf2fb95742423789681ca2e24ddf0c98
Diffstat (limited to 'resources')
-rw-r--r-- | resources/libraries/python/ContainerUtils.py | 16 |
1 files changed, 11 insertions, 5 deletions
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)) |