From bb0b4aa526d677d387d05bdba81ae2dc3607bf92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Ospal=C3=BD?= Date: Thu, 10 Dec 2020 17:30:27 +0100 Subject: [PATCH] B OpenNebula/one#5086: Add fuse support (#541) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit solves issues with creating new VM images based on the docker images inside a container environment. If fuse2fs command is present then prefer its use instead of the default mount command which will work only under root or otherwise privileged user. This commit solves the mounting issue inside the rootless container environment. Also add a new environment file to the oned supervisord service so we can start oned process with some additional env. variables - notably DOCKER_HOST. Signed-off-by: Petr OspalĂ˝ --- .../services/supervisor/centos8/scripts/opennebula.sh | 1 + src/mad/sh/create_container_image.sh | 8 +++++++- src/mad/sh/create_docker_image.sh | 8 +++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/share/pkgs/services/supervisor/centos8/scripts/opennebula.sh b/share/pkgs/services/supervisor/centos8/scripts/opennebula.sh index b49bf143d8..690551368b 100755 --- a/share/pkgs/services/supervisor/centos8/scripts/opennebula.sh +++ b/share/pkgs/services/supervisor/centos8/scripts/opennebula.sh @@ -40,6 +40,7 @@ msg "Database is running - continue" for envfile in \ /var/run/one/ssh-agent.env \ + /etc/sysconfig/oned \ ; do if [ -f "$envfile" ] ; then diff --git a/src/mad/sh/create_container_image.sh b/src/mad/sh/create_container_image.sh index 2908f5f8ba..2f839c1ac6 100755 --- a/src/mad/sh/create_container_image.sh +++ b/src/mad/sh/create_container_image.sh @@ -46,7 +46,13 @@ esac #------------------------------------------------------------------------------- # Mount container disk image and untar rootfs contents to it #------------------------------------------------------------------------------- -mount $tmp_dir/$id.raw $tmp_dir/$id + +# try first to mount with the fuse2fs command and if that fails fallback to the +# regular mount +if ! fuse2fs -o noexec,nodev,nosuid $tmp_dir/$id.raw $tmp_dir/$id >/dev/null 2>&1 ; then + mount -o noexec,nodev,nosuid $tmp_dir/$id.raw $tmp_dir/$id +fi + chown $USER:$GROUP $tmp_dir/$id tar $untar_options $tmp_dir/$id.$extension -C $tmp_dir/$id > /dev/null 2>&1 diff --git a/src/mad/sh/create_docker_image.sh b/src/mad/sh/create_docker_image.sh index d0268bcb54..01e0d31e12 100755 --- a/src/mad/sh/create_docker_image.sh +++ b/src/mad/sh/create_docker_image.sh @@ -59,7 +59,13 @@ fi trap clean EXIT # Mount container disk image and untar rootfs contents to it -mount -o noexec,nodev,nosuid $img_raw $dockerdir/mnt > /dev/null 2>&1 + +# try first to mount with the fuse2fs command and if that fails fallback to the +# regular mount +if ! fuse2fs -o noexec,nodev,nosuid $img_raw $dockerdir/mnt >/dev/null 2>&1 ; then + mount -o noexec,nodev,nosuid $img_raw $dockerdir/mnt +fi + chmod o+w $dockerdir/mnt tar xpf $tarball -C $dockerdir/mnt > /dev/null 2>&1