Disable ext4 userns when running in a container

/sys is read-only when using an LXD contianer due
to lxcfs. So detect if we are running the charm inside
a container and prevent ext4 userns from being
configured.

Closes-Bug: #1635659

Change-Id: Ia0668ea473ec1e80dd8b0a1136061a430883b0ec
Signed-off-by: Chuck Short <chuck.short@canonical.com>
This commit is contained in:
Chuck Short 2016-10-21 10:47:37 -04:00
parent f389556225
commit c0d0fc5041
1 changed files with 3 additions and 1 deletions

View File

@ -425,7 +425,9 @@ def configure_lxd_host():
if ubuntu_release >= 'xenial':
modprobe('netlink_diag')
if os.path.exists(EXT4_USERNS_MOUNTS):
# /sys is read-only when using a container
container_check = check_output(['systemd-detect-virt']).strip()
if (container_check != 'lxc' and os.path.exists(EXT4_USERNS_MOUNTS)):
with open(EXT4_USERNS_MOUNTS, 'w') as userns_mounts:
userns_mounts.write(
'Y\n' if config('enable-ext4-userns') else 'N\n'