From: Thierry Parmentelat Date: Wed, 26 Mar 2014 11:04:18 +0000 (+0100) Subject: an attempt to make VM creation more robust, as more often than expected we fail that... X-Git-Tag: 5.3.2~1 X-Git-Url: http://git.onelab.eu/?p=build.git;a=commitdiff_plain;h=78ed9f1272859f95a55763d5807b1e6276dc6a14 an attempt to make VM creation more robust, as more often than expected we fail that step because of this lock thing --- diff --git a/lbuild-initvm.sh b/lbuild-initvm.sh index c65026c8..ee03232e 100755 --- a/lbuild-initvm.sh +++ b/lbuild-initvm.sh @@ -104,13 +104,12 @@ function fedora_install() { cache=/var/cache/lxc/fedora/$arch/$release - mkdir -p /var/lock/subsys/ ( - flock -n -x 200 || { echo "Cache repository is busy." ; return 1 ; } + flock --exclusive --timeout 60 200 || { echo "Cache repository is busy." ; return 1 ; } if [ ! -e "$cache/rootfs" ]; then echo "Getting cache download in $cache/rootfs ... " - fedora_download || { echo "Failed to download 'fedora base'"; return 1; } + fedora_download $cache || { echo "Failed to download 'fedora base'"; return 1; } else echo "Updating cache $cache/rootfs ..." if ! yum --installroot $cache/rootfs -y --nogpgcheck update ; then @@ -120,18 +119,21 @@ function fedora_install() { fi fi - echo "Copy $cache/rootfs to $lxc_root ... " + echo "Filling $lxc_root from $cache/rootfs ... " rsync -a $cache/rootfs/ $lxc_root/ return 0 - ) 200>/var/lock/subsys/lxc + ) 200> $cache/lock return $? } function fedora_download() { set -x + + cache=$1; shift + # check the mini fedora was not already downloaded INSTALL_ROOT=$cache/partial echo $INSTALL_ROOT