mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
More boring stuff to try to hunt/fix the 'Error: in use' nightmare -_-
This commit is contained in:
parent
a315eacfa7
commit
0b871d6bfa
1 changed files with 8 additions and 5 deletions
13
lib/lxc.sh
13
lib/lxc.sh
|
@ -82,16 +82,16 @@ LOAD_LXC_SNAPSHOT () {
|
||||||
# Remove swap files before restoring the snapshot.
|
# Remove swap files before restoring the snapshot.
|
||||||
CLEAN_SWAPFILES
|
CLEAN_SWAPFILES
|
||||||
|
|
||||||
local retry=0
|
local retry_lxc=0
|
||||||
while [[ $retry -lt 10 ]]
|
while [[ ${retry_lxc} -lt 10 ]]
|
||||||
do
|
do
|
||||||
LXC_STOP $LXC_NAME || true
|
LXC_STOP $LXC_NAME || true
|
||||||
lxc restore $LXC_NAME $snapname && break || retry+=1
|
lxc restore $LXC_NAME $snapname && break || retry_lxc+=1
|
||||||
log_warning "Failed to stop LXC and restore snapshot? Retrying in 20 sec ..."
|
log_warning "Failed to stop LXC and restore snapshot? Retrying in 20 sec ..."
|
||||||
sleep 20
|
sleep 20
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $retry -ge 10 ]]
|
if [[ ${retry_lxc} -ge 10 ]]
|
||||||
then
|
then
|
||||||
log_error "Failed to restore snapshot ? The next step may miserably crash because of this ... if this happens to often, maybe restarting the LXD daemon can help ..."
|
log_error "Failed to restore snapshot ? The next step may miserably crash because of this ... if this happens to often, maybe restarting the LXD daemon can help ..."
|
||||||
fi
|
fi
|
||||||
|
@ -128,10 +128,13 @@ LXC_STOP () {
|
||||||
# (We also use timeout 30 in front of the command because sometime lxc
|
# (We also use timeout 30 in front of the command because sometime lxc
|
||||||
# commands can hang forever despite the --timeout >_>...)
|
# commands can hang forever despite the --timeout >_>...)
|
||||||
timeout 30 lxc stop --timeout 15 $container_to_stop 2>/dev/null
|
timeout 30 lxc stop --timeout 15 $container_to_stop 2>/dev/null
|
||||||
|
local ret=$?
|
||||||
|
|
||||||
# If the command times out, then add the option --force
|
# If the command times out, then add the option --force
|
||||||
if [ $? -eq 124 ]; then
|
if [ $ret -eq 124 ]; then
|
||||||
timeout 30 lxc stop --timeout 15 $container_to_stop --force 2>/dev/null
|
timeout 30 lxc stop --timeout 15 $container_to_stop --force 2>/dev/null
|
||||||
|
elif [ $ret -ne 0 ]
|
||||||
|
log_warning "Tried to stop lxc, got ret $ret"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue