Skip to content

Commit

Permalink
F OpenNebula#4089: Improve firecracker clean.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian González committed Mar 6, 2020
1 parent 1ddc29c commit dd1d9f2
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/vmm_mad/remotes/lib/firecracker/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #

source /var/tmp/one/scripts_common.sh

# exit when any command fails
set -e

Expand Down Expand Up @@ -62,14 +64,20 @@ function wait_cgroup () {
[ ! -z "$(lsof $1)" ]; do continue; done
}

DIR="$CGROUP_PATH/cpu/firecracker/$VM_NAME"
wait_cgroup $DIR
if [ -d "$DIR" ]; then rmdir "$DIR"; fi
function clean_cgroups () {
DIR="$CGROUP_PATH/cpu/firecracker/$VM_NAME"
wait_cgroup $DIR
if [ -d "$DIR" ]; then rmdir "$DIR"; fi

DIR="$CGROUP_PATH/cpuset/firecracker/$VM_NAME"
wait_cgroup $DIR
if [ -d "$DIR" ]; then rmdir "$DIR"; fi

DIR="$CGROUP_PATH/pids/firecracker/$VM_NAME"
wait_cgroup $DIR
if [ -d "$DIR" ]; then rmdir "$DIR"; fi
}

DIR="$CGROUP_PATH/cpuset/firecracker/$VM_NAME"
wait_cgroup $DIR
if [ -d "$DIR" ]; then rmdir "$DIR"; fi
retry 3 clean_cgroups

DIR="$CGROUP_PATH/pids/firecracker/$VM_NAME"
wait_cgroup $DIR
if [ -d "$DIR" ]; then rmdir "$DIR"; fi
exit 0

0 comments on commit dd1d9f2

Please sign in to comment.