mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Add a damn retry system when failing to stop LXC or restore snapshot ...
This commit is contained in:
parent
af359e9dfe
commit
ba3a19cfcd
1 changed files with 12 additions and 2 deletions
14
lib/lxc.sh
14
lib/lxc.sh
|
@ -82,9 +82,19 @@ LOAD_LXC_SNAPSHOT () {
|
|||
# Remove swap files before restoring the snapshot.
|
||||
CLEAN_SWAPFILES
|
||||
|
||||
LXC_STOP $LXC_NAME
|
||||
local retry=0
|
||||
while [[ $retry -lt 5 ]]
|
||||
then
|
||||
LXC_STOP $LXC_NAME || true
|
||||
lxc restore $LXC_NAME $snapname && break || retry+=1
|
||||
log_warning "Failed to stop LXC and restore snapshot? Retrying in 10 sec ..."
|
||||
sleep 20
|
||||
fi
|
||||
|
||||
lxc restore $LXC_NAME $snapname || 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 ..."
|
||||
if [[ $retry -ge 3 ]]
|
||||
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 ..."
|
||||
fi
|
||||
|
||||
lxc start $LXC_NAME
|
||||
_LXC_START_AND_WAIT $LXC_NAME
|
||||
|
|
Loading…
Add table
Reference in a new issue