From 7c5acb6fdb0d73a64b1d410fc3a99422b467efe5 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Tue, 2 May 2017 14:09:06 -0400 Subject: [PATCH] Conditional nodepool logic Make the logic around reading the generated nodepool files conditional based on the presence of /etc/nodepool/provider. When using these scripts outside of nodepool, these files are likely not present, so this code should handle that case gracefully. For tripleo.sh --setup-nodepool-files, remove the generation of /etc/nodepool/provider so that the conditional is not unintentionally triggered. Change-Id: I13d78d371b3157a151a7ef861cfa7a293a39f2a2 --- scripts/tripleo.sh | 3 --- toci_gate_test-oooq.sh | 42 ++++++++++++++++++++++-------------------- toci_gate_test-orig.sh | 4 ++-- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/scripts/tripleo.sh b/scripts/tripleo.sh index 959290884..0413c3554 100755 --- a/scripts/tripleo.sh +++ b/scripts/tripleo.sh @@ -1493,9 +1493,6 @@ function setup_nodepool_files { echo $PRIMARY_NODE_IP > /etc/nodepool/node echo $PRIMARY_NODE_IP > /etc/nodepool/node_private - echo "NODEPOOL_REGION=$NODEPOOL_REGION" > /etc/nodepool/provider - echo "NODEPOOL_CLOUD=$NODEPOOL_CLOUD" >> /etc/nodepool/provider - log "Setup nodepool files - DONE" } diff --git a/toci_gate_test-oooq.sh b/toci_gate_test-oooq.sh index c33b4df09..4e94f58c4 100755 --- a/toci_gate_test-oooq.sh +++ b/toci_gate_test-oooq.sh @@ -16,30 +16,32 @@ fi source $TRIPLEO_ROOT/tripleo-ci/scripts/oooq_common_functions.sh -# this sets -# NODEPOOL_PROVIDER (e.g tripleo-test-cloud-rh1) -# NODEPOOL_CLOUD (e.g.tripleo-test-cloud-rh1) -# NODEPOOL_REGION (e.g. regionOne) -# NODEPOOL_AZ -source /etc/nodepool/provider +if [ -f /etc/nodepool/provider ] ; then + # this sets + # NODEPOOL_PROVIDER (e.g tripleo-test-cloud-rh1) + # NODEPOOL_CLOUD (e.g.tripleo-test-cloud-rh1) + # NODEPOOL_REGION (e.g. regionOne) + # NODEPOOL_AZ + source /etc/nodepool/provider -# source variables common across all the scripts. -source /etc/ci/mirror_info.sh + # source variables common across all the scripts. + source /etc/ci/mirror_info.sh -# set up distribution mirrors in openstack -NODEPOOL_MIRROR_HOST=${NODEPOOL_MIRROR_HOST:-mirror.$NODEPOOL_REGION.$NODEPOOL_CLOUD.openstack.org} -NODEPOOL_MIRROR_HOST=$(echo $NODEPOOL_MIRROR_HOST|tr '[:upper:]' '[:lower:]') -export CENTOS_MIRROR=http://$NODEPOOL_MIRROR_HOST/centos -export EPEL_MIRROR=http://$NODEPOOL_MIRROR_HOST/epel + # set up distribution mirrors in openstack + NODEPOOL_MIRROR_HOST=${NODEPOOL_MIRROR_HOST:-mirror.$NODEPOOL_REGION.$NODEPOOL_CLOUD.openstack.org} + NODEPOOL_MIRROR_HOST=$(echo $NODEPOOL_MIRROR_HOST|tr '[:upper:]' '[:lower:]') + export CENTOS_MIRROR=http://$NODEPOOL_MIRROR_HOST/centos + export EPEL_MIRROR=http://$NODEPOOL_MIRROR_HOST/epel -# host setup -if [ $NODEPOOL_CLOUD == 'tripleo-test-cloud-rh1' ]; then - source $(dirname $0)/scripts/rh1.env + # host setup + if [ $NODEPOOL_CLOUD == 'tripleo-test-cloud-rh1' ]; then + source $(dirname $0)/scripts/rh1.env - # In order to save space remove the cached git repositories, at this point in - # CI the ones we are interested in have been cloned to /opt/stack/new. We - # can also remove some distro images cached on the images. - sudo rm -rf /opt/git /opt/stack/cache/files/mysql.qcow2 /opt/stack/cache/files/ubuntu-12.04-x86_64.tar.gz + # In order to save space remove the cached git repositories, at this point in + # CI the ones we are interested in have been cloned to /opt/stack/new. We + # can also remove some distro images cached on the images. + sudo rm -rf /opt/git /opt/stack/cache/files/mysql.qcow2 /opt/stack/cache/files/ubuntu-12.04-x86_64.tar.gz + fi fi # create logs dir (check if collect-logs doesn't already do this) diff --git a/toci_gate_test-orig.sh b/toci_gate_test-orig.sh index d0d189191..6f184eb53 100755 --- a/toci_gate_test-orig.sh +++ b/toci_gate_test-orig.sh @@ -3,8 +3,8 @@ set -eux export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' # Mirrors # NOTE(pabelanger): We have access to AFS mirrors, lets use them. -source /etc/nodepool/provider -source /etc/ci/mirror_info.sh +[ -f /etc/nodepool/provider ] && source /etc/nodepool/provider +[ -f /etc/ci/mirror_info.sh ] && source /etc/ci/mirror_info.sh source $(dirname $0)/scripts/common_vars.bash NODEPOOL_MIRROR_HOST=${NODEPOOL_MIRROR_HOST:-mirror.$NODEPOOL_REGION.$NODEPOOL_CLOUD.openstack.org}