1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-20 10:50:08 +03:00

F #4089: Small fixes for fc driver

This commit is contained in:
Ruben S. Montero 2020-03-09 13:11:17 +01:00
parent c05b9588e8
commit 65217a5bf0
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
3 changed files with 19 additions and 10 deletions

View File

@ -38,13 +38,13 @@ microvm.gen_deployment_file
# Create microVM
rc = microvm.create
exit(-1) unless rc
sleep(1)
# Make sure process have started
sleep(1)
if microvm.get_pid == -1
if !rc || microvm.get_pid == -1
STDERR.puts 'MicroVM failed to start.'
microvm.clean(false)
exit(-1)
end

View File

@ -24,12 +24,14 @@ set -e
CGROUP_PATH=""
VM_NAME=""
CGROUP_TO=60
ONLY_UMOUNT=""
while getopts ":c:v:t:" opt; do
while getopts ":c:v:t:o" opt; do
case $opt in
c) CGROUP_PATH="$OPTARG" ;;
v) VM_NAME="$OPTARG" ;;
t) CGROUP_TO=$OPTARG ;;
o) ONLY_UMOUNT="1"
esac
done
@ -49,9 +51,6 @@ rm -f "$ROOTFS_PATH/firecracker"
# Unmount VM directory
umount "$ROOTFS_PATH"
# Remove VM chroot directory
rm -rf $(dirname $ROOTFS_PATH)
#-------------------------------------------------------------------------------
# Wait for a cgroup to not being used
# @param $1 - Path to cgroup
@ -80,4 +79,13 @@ function clean_cgroups () {
retry 3 clean_cgroups
#-------------------------------------------------------------------------------
# Remove VM chroot directory
#-------------------------------------------------------------------------------
if [ -n "${ONLY_UMOUNT}" ]; then
exit 0
fi
rm -rf $(dirname $ROOTFS_PATH)
exit 0

View File

@ -88,7 +88,7 @@ class MicroVM
end
def get_pid
rc, stdout, = Command.execute("ps auxwww | grep -E '^.*firecracker.*\\-\\-id[[:blank:]]+#{@one.vm_name}[[:blank:]]+'",
rc, stdout, = Command.execute("ps auxwww | grep '^.*firecracker.*\\<#{@one.vm_name}\\>' | grep -v grep",
false)
if !rc.zero? || stdout.nil?
@ -227,11 +227,12 @@ class MicroVM
end
# Clean resources and directories after shuttingdown the microVM
def clean
def clean(delete=true)
cgroup_path = @one.fcrc[:cgroup_location]
timeout = Integer(@one.fcrc[:cgroup_delete_timeout])
params = "-c #{cgroup_path} -v #{@one.vm_name} -t #{timeout}"
params << " -o" unless delete
cmd = "sudo #{@clean_sh} #{params}"