From 4b79476969def3e3510f3859e1539386b5b0d471 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 27 Sep 2017 16:46:07 +0100 Subject: xci: scripts: start-new-vm.sh: Do not allow multiple build-dib-os processes apt-get is really unhappy when another instance is running and fails with the following error: E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it? Change-Id: I2fe343fdab8438cb112cce0a4f81c7e3977c55f9 Signed-off-by: Markos Chandras --- xci/scripts/vm/build-dib-os.sh | 2 +- xci/scripts/vm/start-new-vm.sh | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'xci/scripts') diff --git a/xci/scripts/vm/build-dib-os.sh b/xci/scripts/vm/build-dib-os.sh index 78eaff2d..2f788006 100755 --- a/xci/scripts/vm/build-dib-os.sh +++ b/xci/scripts/vm/build-dib-os.sh @@ -7,7 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -set -e +set -ex # This only works on ubuntu hosts lsb_release -i | grep -q -i ubuntu || { echo "This script only works on Ubuntu distros"; exit 1; } diff --git a/xci/scripts/vm/start-new-vm.sh b/xci/scripts/vm/start-new-vm.sh index c374071c..991637a6 100755 --- a/xci/scripts/vm/start-new-vm.sh +++ b/xci/scripts/vm/start-new-vm.sh @@ -8,7 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -set -e +set -ex lsb_release -i | grep -q -i ubuntu || { echo "This script only works on Ubuntu distros"; exit 1; } @@ -38,8 +38,18 @@ declare -r BASE_PATH=$(dirname $(readlink -f $0) | sed "s@/xci/.*@@") echo "Preparing new virtual machine '${NAME}'..." # NOTE(hwoarang) This should be removed when we move the dib images to a central place +_retries=20 echo "Building '${OS}' image (tail build.log for progress and failures)..." -$BASE_PATH/xci/scripts/vm/build-dib-os.sh ${OS} > build.log 2>&1 +while [[ $_retries -ne 0 ]]; do + if pgrep build-dib-os.sh &>/dev/null; then + echo "There is another dib process running... ($_retries retries left)" + sleep 60 + (( _retries = _retries - 1 )) + else + $BASE_PATH/xci/scripts/vm/build-dib-os.sh ${OS} > build.log 2>&1 + break + fi +done [[ ! -e ${OS}.qcow2 ]] && echo "${OS}.qcow2 not found! This should never happen!" && exit 1 -- cgit 1.2.3-korg From 1e58883c62e464b1d7583489f67b10dcd13f5928 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 27 Sep 2017 11:28:43 +0100 Subject: xci: scripts: start-new-vm.sh: Use 'unsafe' cache for the clean vm disk This is not a production virtual machine and we don't care if we lose data in case it's killed unexpectedly so we can just ignore the 'flush' commands from the guest. This will also improve the overall I/O in the VMs. Change-Id: Ib486a073f667e22f4a1e65a220ac553874f708cc Signed-off-by: Markos Chandras --- xci/scripts/vm/start-new-vm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xci/scripts') diff --git a/xci/scripts/vm/start-new-vm.sh b/xci/scripts/vm/start-new-vm.sh index 991637a6..807e1c0c 100755 --- a/xci/scripts/vm/start-new-vm.sh +++ b/xci/scripts/vm/start-new-vm.sh @@ -88,7 +88,7 @@ sudo virsh undefine ${NAME} || true echo "Installing virtual machine '${NAME}'..." sudo virt-install -n ${NAME} --memory ${MEMORY} --vcpus ${NCPUS} --cpu ${CPU} \ - --import --disk=${OS}.qcow2 --network network=${NETWORK} \ + --import --disk=${OS}.qcow2,cache=unsafe --network network=${NETWORK} \ --graphics none --hvm --noautoconsole _retries=30 -- cgit 1.2.3-korg From f6a885ffabd77ef9abb80c49d65772c97d9aee1e Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 26 Sep 2017 09:22:58 +0100 Subject: xci: scripts: start-new-vm.sh: Print dib output when running on CI Until we are able to fetch the dib images from external resources, we need to build them as part of the job. diskimage-builder can sometimes fail so we need to be able to see the log for debug purposes. Change-Id: Iab8bfba08daa7095cf76537f629c8e7bf6330b17 Signed-off-by: Markos Chandras --- xci/scripts/vm/build-dib-os.sh | 2 +- xci/scripts/vm/start-new-vm.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'xci/scripts') diff --git a/xci/scripts/vm/build-dib-os.sh b/xci/scripts/vm/build-dib-os.sh index 2f788006..78eaff2d 100755 --- a/xci/scripts/vm/build-dib-os.sh +++ b/xci/scripts/vm/build-dib-os.sh @@ -7,7 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -set -ex +set -e # This only works on ubuntu hosts lsb_release -i | grep -q -i ubuntu || { echo "This script only works on Ubuntu distros"; exit 1; } diff --git a/xci/scripts/vm/start-new-vm.sh b/xci/scripts/vm/start-new-vm.sh index 807e1c0c..cba1a394 100755 --- a/xci/scripts/vm/start-new-vm.sh +++ b/xci/scripts/vm/start-new-vm.sh @@ -8,7 +8,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -set -ex +set -e lsb_release -i | grep -q -i ubuntu || { echo "This script only works on Ubuntu distros"; exit 1; } @@ -46,7 +46,11 @@ while [[ $_retries -ne 0 ]]; do sleep 60 (( _retries = _retries - 1 )) else - $BASE_PATH/xci/scripts/vm/build-dib-os.sh ${OS} > build.log 2>&1 + if [[ -n ${JENKINS_HOME} ]]; then + $BASE_PATH/xci/scripts/vm/build-dib-os.sh ${OS} 2>&1 | tee build.log + else + $BASE_PATH/xci/scripts/vm/build-dib-os.sh ${OS} > build.log 2>&1 + fi break fi done -- cgit 1.2.3-korg From 44cdd0b1462530977b3efae4ac9d17dcb6c4c12c Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 27 Sep 2017 15:56:25 +0100 Subject: xci: scripts: start-new-vm.sh: Fix paths for default XCI test The XCI test is located in ~/releng-xci inside the new VM so we need to look there for an existing one or for executing it after the default one has been created and copied to the remote host. Change-Id: Ieb195293da7832bcb5d29c8a28cc3477205f2e5e Signed-off-by: Markos Chandras --- xci/scripts/vm/start-new-vm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xci/scripts') diff --git a/xci/scripts/vm/start-new-vm.sh b/xci/scripts/vm/start-new-vm.sh index cba1a394..65133edc 100755 --- a/xci/scripts/vm/start-new-vm.sh +++ b/xci/scripts/vm/start-new-vm.sh @@ -191,7 +191,7 @@ set +e _has_test=true echo "Verifying test script exists..." -$vm_ssh $_ip "bash -c 'stat ~/$(basename ${BASE_PATH})/run_jenkins_test.sh'" +$vm_ssh $_ip "bash -c 'stat ~/releng-xci/run_jenkins_test.sh'" if [[ $? != 0 ]]; then echo "Failed to find a 'run_jenkins_test.sh' script..." if ${DEFAULT_XCI_TEST}; then @@ -210,7 +210,7 @@ fi if ${_has_test}; then echo "Running test..." - $vm_ssh $_ip "bash ~/$(basename ${BASE_PATH})/run_jenkins_test.sh" + $vm_ssh $_ip "bash ~/releng-xci/run_jenkins_test.sh" xci_error=$? else echo "No jenkins test was found. The virtual machine will remain idle!" -- cgit 1.2.3-korg