diff options
author | Markos Chandras <mchandras@suse.de> | 2018-01-23 10:25:12 +0000 |
---|---|---|
committer | Markos Chandras <mchandras@suse.de> | 2018-01-23 10:25:12 +0000 |
commit | 0bfe96fb45b6f69d93f1e088d27aef8b17906d32 (patch) | |
tree | 0c58c277a2a17d086a6d0e630702925ed9ecdd31 | |
parent | 862219cb61d57598029fc3dfe21923ccd00df257 (diff) |
xci: scripts: vm: Retry when timer expires
We should look again for active package managers when the timer expires
to avoid locking issues.
Change-Id: I88f0299a87befce17d11ba7581f0330979a25345
Signed-off-by: Markos Chandras <mchandras@suse.de>
-rwxr-xr-x | xci/scripts/vm/start-new-vm.sh | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/xci/scripts/vm/start-new-vm.sh b/xci/scripts/vm/start-new-vm.sh index 0af2a359..3048d1b9 100755 --- a/xci/scripts/vm/start-new-vm.sh +++ b/xci/scripts/vm/start-new-vm.sh @@ -112,15 +112,6 @@ if ! sudo -n "true"; then exit 1 fi -# Wait 30-120 seconds so we avoid running multiple instances of pkg manager. Of course -# this will not work as it should if there is an external process running a package -# manager instance. However, since this script is only being execute on CI nodes which -# we have complete control it should be mostly fine. -backoff_time=0 -while [[ ${backoff_time} -le 30 ]]; do - backoff_time=$(( $RANDOM % 120 )) -done - case ${ID,,} in *suse) pkg_mgr_cmd="sudo zypper -q -n install virt-manager qemu-kvm qemu-tools libvirt-daemon docker libvirt-client libvirt-daemon-driver-qemu iptables ebtables dnsmasq" @@ -133,9 +124,10 @@ case ${ID,,} in ;; esac -if pgrep -fa "${pkg_mgr_cmd%*install*}" 2>&1; then - sleep ${backoff_time} -fi +while true; do + pgrep -fa "${pkg_mgr_cmd%*install*}" 2>&1 && sleep 60 || break +done + eval ${pkg_mgr_cmd} echo "Ensuring libvirt and docker services are running..." |