From 0b699ed29ab5cb49c5cb185522da0039747be662 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 24 Nov 2023 21:45:28 +0100 Subject: [PATCH] Add a stupid hack to handle the stupid 'Error: in use' from LXC : just keep retring to restore the snapshot until it somehow works >_> --- utils.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/utils.sh b/utils.sh index 0d7f55a..1ec3ace 100755 --- a/utils.sh +++ b/utils.sh @@ -104,11 +104,27 @@ create_snapshot() restore_snapshot() { - local instance_to_publish=$1 + local lxc_name=$1 local ynh_version=$2 local snapshot=$3 + local retry_lxc=0 - lxc restore "$instance_to_publish" "$ynh_version-$snapshot" + while [[ ${retry_lxc} -lt 10 ]] + do + lxc restore "$lxc_name" "$ynh_version-$snapshot" && break || retry_lxc=$(($retry_lxc+1)) + info "Failed to restore snapshot? Retrying in 10 sec ..." + if [[ ${retry_lxc} -ge 3 ]] + then + warn "If this keeps happening, restarting the LXD daemon might help :| ..." + fi + sleep 10 + done + + if [[ ${retry_lxc} -ge 10 ]] + then + error "Failed to properly restore the snapshot zrgmblg" + return 1 + fi } # These lines are used to extract the dependencies/recommendations from the debian/control file.