diff options
author | Markos Chandras <mchandras@suse.de> | 2017-09-28 07:43:34 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-09-28 07:43:34 +0000 |
commit | a9ec5d588eaeece632ad9f0e5f27b7313a291d6a (patch) | |
tree | 7ea1ee4e660e4e6227afe4321c057e9abead3593 | |
parent | 7056b91177bcfb2f745cbb3d4c6e55005c59b9c7 (diff) | |
parent | 44cdd0b1462530977b3efae4ac9d17dcb6c4c12c (diff) |
Merge changes from topic 'fix-vm-on-jenkins'
* changes:
xci: scripts: start-new-vm.sh: Fix paths for default XCI test
xci: Replace ANSIBLE_VERBOSITY with XCI_ANSIBLE_VERBOSITY
xci: scripts: start-new-vm.sh: Print dib output when running on CI
xci: scripts: start-new-vm.sh: Use 'unsafe' cache for the clean vm disk
xci: xci-deploy.sh: Make sure all local Ansible installations are gone
xci: scripts: start-new-vm.sh: Do not allow multiple build-dib-os processes
-rwxr-xr-x | bifrost/scripts/bifrost-provision.sh | 10 | ||||
-rwxr-xr-x | xci/config/user-vars | 6 | ||||
-rwxr-xr-x | xci/scripts/vm/start-new-vm.sh | 22 | ||||
-rwxr-xr-x | xci/xci-deploy.sh | 27 |
4 files changed, 44 insertions, 21 deletions
diff --git a/bifrost/scripts/bifrost-provision.sh b/bifrost/scripts/bifrost-provision.sh index d4d1f96a..bd9493e6 100755 --- a/bifrost/scripts/bifrost-provision.sh +++ b/bifrost/scripts/bifrost-provision.sh @@ -91,10 +91,10 @@ cd $BIFROST_HOME/playbooks # Syntax check of dynamic inventory test path for task in syntax-check list-tasks; do - ${ANSIBLE} -i inventory/localhost \ + ${ANSIBLE} ${XCI_ANSIBLE_VERBOSITY} -i inventory/localhost \ test-bifrost-create-vm.yaml \ --${task} - ${ANSIBLE} -i inventory/localhost \ + ${ANSIBLE} ${XCI_ANSIBLE_VERBOSITY} -i inventory/localhost \ ${TEST_PLAYBOOK} \ --${task} \ -e testing_user=${TESTING_USER} @@ -111,7 +111,8 @@ if [[ -e /etc/centos-release ]]; then fi # Create the VMS -${ANSIBLE} -i inventory/localhost \ +${ANSIBLE} ${XCI_ANSIBLE_VERBOSITY} \ + -i inventory/localhost \ test-bifrost-create-vm.yaml \ -e test_vm_num_nodes=${TEST_VM_NUM_NODES} \ -e test_vm_memory_size=${VM_MEMORY_SIZE} \ @@ -120,7 +121,8 @@ ${ANSIBLE} -i inventory/localhost \ -e ${INVENTORY_FILE_FORMAT}=${BAREMETAL_DATA_FILE} # Execute the installation and VM startup test -${ANSIBLE} -i inventory/bifrost_inventory.py \ +${ANSIBLE} ${XCI_ANSIBLE_VERBOSITY} \ + -i inventory/bifrost_inventory.py \ ${TEST_PLAYBOOK} \ -e use_cirros=${USE_CIRROS} \ -e testing_user=${TESTING_USER} \ diff --git a/xci/config/user-vars b/xci/config/user-vars index ecde6db9..7c99ee9d 100755 --- a/xci/config/user-vars +++ b/xci/config/user-vars @@ -49,10 +49,10 @@ export OPNFV_OSA_PLAYBOOK=${OPNFV_OSA_PLAYBOOK:-"$OPENSTACK_OSA_PATH/playbooks/s # Set the verbosity for ansible # # Examples: -# ANSIBLE_VERBOSITY="-v" +# XCI_ANSIBLE_VERBOSITY="-v" # or -# ANSIBLE_VERBOSITY="-vvvv" -export ANSIBLE_VERBOSITY=${ANSIBLE_VERBOSITY:-""} +# XCI_ANSIBLE_VERBOSITY="-vvvv" +export XCI_ANSIBLE_VERBOSITY=${XCI_ANSIBLE_VERBOSITY:-""} export LOG_PATH=${LOG_PATH:-${XCI_DEVEL_ROOT}/opnfv/logs} export RUN_TEMPEST=${RUN_TEMPEST:-false} # Set this to to true to force XCI to re-create the target OS images diff --git a/xci/scripts/vm/start-new-vm.sh b/xci/scripts/vm/start-new-vm.sh index c374071c..65133edc 100755 --- a/xci/scripts/vm/start-new-vm.sh +++ b/xci/scripts/vm/start-new-vm.sh @@ -38,8 +38,22 @@ 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 + 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 [[ ! -e ${OS}.qcow2 ]] && echo "${OS}.qcow2 not found! This should never happen!" && exit 1 @@ -78,7 +92,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 @@ -177,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 @@ -196,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!" diff --git a/xci/xci-deploy.sh b/xci/xci-deploy.sh index 95856105..80ff53b6 100755 --- a/xci/xci-deploy.sh +++ b/xci/xci-deploy.sh @@ -123,7 +123,7 @@ cd $XCI_PATH/playbooks sudo pip uninstall -y ansible || true sudo -H pip uninstall -y ansible || true sudo pip install ansible==${XCI_ANSIBLE_PIP_VERSION} -ansible-playbook -i inventory provision-vm-nodes.yml +ansible-playbook ${XCI_ANSIBLE_VERBOSITY} -i inventory provision-vm-nodes.yml cd ${OPENSTACK_BIFROST_PATH} bash ./scripts/bifrost-provision.sh echo "-----------------------------------------------------------------------" @@ -143,10 +143,17 @@ echo echo "Info: Configuring localhost for openstack-ansible" echo "-----------------------------------------------------------------------" -# NOTE(hwoarang) we need newer ansible to work on the OSA playbooks +# NOTE(hwoarang) we need newer ansible to work on the OSA playbooks. Make sure +# all installations are gone. This is ugly and has to be removed as soon as we +# are able to deploy bifrost in vent or when bifrost start working with newest +# ansible +pip uninstall -y ansible || true +sudo -H pip uninstall -y ansible || true sudo pip install --force-reinstall ansible==${XCI_ANSIBLE_PIP_VERSION} +# Start fresh +hash -r cd $XCI_PATH/playbooks -ansible-playbook -i inventory configure-localhost.yml +ansible-playbook ${XCI_ANSIBLE_VERBOSITY} -i inventory configure-localhost.yml echo "-----------------------------------------------------------------------" echo "Info: Configured localhost host for openstack-ansible" @@ -164,7 +171,7 @@ echo "Info: Configured localhost host for openstack-ansible" echo "Info: Configuring opnfv deployment host for openstack-ansible" echo "-----------------------------------------------------------------------" cd ${XCI_DEVEL_ROOT} -ansible-playbook -i ${OPNFV_XCI_PATH}/playbooks/inventory ${OPNFV_XCI_PATH}/playbooks/configure-opnfvhost.yml +ansible-playbook ${XCI_ANSIBLE_VERBOSITY} -i ${OPNFV_XCI_PATH}/playbooks/inventory ${OPNFV_XCI_PATH}/playbooks/configure-opnfvhost.yml echo "-----------------------------------------------------------------------" echo "Info: Configured opnfv deployment host for openstack-ansible" @@ -183,7 +190,7 @@ if [[ $XCI_FLAVOR != "aio" ]]; then echo "Info: Configuring target hosts for openstack-ansible" echo "-----------------------------------------------------------------------" cd $OPNFV_XCI_PATH/playbooks - ansible-playbook -i inventory configure-targethosts.yml + ansible-playbook ${XCI_ANSIBLE_VERBOSITY} -i inventory configure-targethosts.yml echo "-----------------------------------------------------------------------" echo "Info: Configured target hosts" fi @@ -195,7 +202,7 @@ fi #------------------------------------------------------------------------------- echo "Info: Setting up target hosts for openstack-ansible" echo "-----------------------------------------------------------------------" -ssh root@$OPNFV_HOST_IP "openstack-ansible \ +ssh root@$OPNFV_HOST_IP "openstack-ansible ${XCI_ANSIBLE_VERBOSITY} \ $OPENSTACK_OSA_PATH/playbooks/setup-hosts.yml | tee setup-hosts.log " scp root@$OPNFV_HOST_IP:~/setup-hosts.log $LOG_PATH/setup-hosts.log echo "-----------------------------------------------------------------------" @@ -217,7 +224,7 @@ echo "Info: Set up target hosts for openstack-ansible successfuly" echo "Info: Gathering facts" echo "-----------------------------------------------------------------------" ssh root@$OPNFV_HOST_IP "cd $OPENSTACK_OSA_PATH/playbooks; \ - ansible -m setup -a gather_subset=network,hardware,virtual all" + ansible ${XCI_ANSIBLE_VERBOSITY} -m setup -a gather_subset=network,hardware,virtual all" echo "-----------------------------------------------------------------------" #------------------------------------------------------------------------------- @@ -228,7 +235,7 @@ echo "-----------------------------------------------------------------------" echo "Info: Setting up infrastructure" echo "-----------------------------------------------------------------------" echo "xci: running ansible playbook setup-infrastructure.yml" -ssh root@$OPNFV_HOST_IP "openstack-ansible \ +ssh root@$OPNFV_HOST_IP "openstack-ansible ${XCI_ANSIBLE_VERBOSITY} \ $OPENSTACK_OSA_PATH/playbooks//setup-infrastructure.yml | tee setup-infrastructure.log" scp root@$OPNFV_HOST_IP:~/setup-infrastructure.log $LOG_PATH/setup-infrastructure.log echo "-----------------------------------------------------------------------" @@ -262,7 +269,7 @@ echo "Info: Database cluster verification successful!" #------------------------------------------------------------------------------- echo "Info: Installing OpenStack on target hosts" echo "-----------------------------------------------------------------------" -ssh root@$OPNFV_HOST_IP "openstack-ansible \ +ssh root@$OPNFV_HOST_IP "openstack-ansible ${XCI_ANSIBLE_VERBOSITY} \ $OPENSTACK_OSA_PATH/playbooks/setup-openstack.yml | tee opnfv-setup-openstack.log" scp root@$OPNFV_HOST_IP:~/opnfv-setup-openstack.log $LOG_PATH/opnfv-setup-openstack.log echo "-----------------------------------------------------------------------" @@ -292,4 +299,4 @@ USERNAME=$(ssh -q root@192.168.122.2 awk "/OS_USERNAME=./" openrc) PASSWORD=$(ssh -q root@192.168.122.2 awk "/OS_PASSWORD=./" openrc) echo "Info: Admin username - ${USERNAME##*=}" echo "Info: Admin password - ${PASSWORD##*=}" -echo "Info: It is recommended to change the default password."
\ No newline at end of file +echo "Info: It is recommended to change the default password." |