From bd36689c2ce122ffd35b74187bd4b9feb5fde5d6 Mon Sep 17 00:00:00 2001 From: Logan V Date: Sun, 12 May 2019 19:22:30 -0500 Subject: [PATCH] Set nodepool mirror PIP_OPTS consistently The bootstrap-ansible script does not always run as a child of the gate-check-commit, so bootstrap-ansible should be prepared to load the nodepool PIP mirrors itself. Move the nodepool mirror detection into a common function so it can be used in both bootstrap-ansible and gate-check-commit. Change-Id: Ie5c8d65aee11d6dba18a0388467783cc6e9e5d36 --- scripts/bootstrap-ansible.sh | 3 +++ scripts/gate-check-commit.sh | 12 ++---------- scripts/scripts-library.sh | 8 ++++++++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/bootstrap-ansible.sh b/scripts/bootstrap-ansible.sh index f4ee86692f..dabf65ac3e 100755 --- a/scripts/bootstrap-ansible.sh +++ b/scripts/bootstrap-ansible.sh @@ -97,6 +97,9 @@ esac # Ensure that our shell knows about the new virtualenv hash -r virtualenv +# Load nodepool PIP mirror settings +load_nodepool_pip_opts + # Ensure we use the HTTPS/HTTP proxy with pip if it is specified if [ -n "$HTTPS_PROXY" ]; then PIP_OPTS+="--proxy $HTTPS_PROXY" diff --git a/scripts/gate-check-commit.sh b/scripts/gate-check-commit.sh index 260ba45fad..757889ee3f 100755 --- a/scripts/gate-check-commit.sh +++ b/scripts/gate-check-commit.sh @@ -81,11 +81,7 @@ log_instance_info run_dstat || true -# If in OpenStack-Infra, set some vars to use the mirror when bootstrapping Ansible -if [[ -e /etc/ci/mirror_info.sh ]]; then - source /etc/ci/mirror_info.sh - export PIP_OPTS="--index-url ${NODEPOOL_PYPI_MIRROR} --trusted-host ${NODEPOOL_MIRROR_HOST} --extra-index-url ${NODEPOOL_WHEEL_MIRROR}" -fi +load_nodepool_pip_opts # Bootstrap Ansible source "${OSA_CLONE_DIR}/scripts/bootstrap-ansible.sh" @@ -169,11 +165,7 @@ if [[ "${ACTION}" == "upgrade" ]]; then unset UPPER_CONSTRAINTS_FILE unset PIP_OPTS - # If in OpenStack-Infra, set some vars to use the mirror when bootstrapping Ansible - if [[ -e /etc/ci/mirror_info.sh ]]; then - source /etc/ci/mirror_info.sh - export PIP_OPTS="--index-url ${NODEPOOL_PYPI_MIRROR} --trusted-host ${NODEPOOL_MIRROR_HOST} --extra-index-url ${NODEPOOL_WHEEL_MIRROR}" - fi + load_nodepool_pip_opts # Source the current scripts-library.sh functions source "${OSA_CLONE_DIR}/scripts/scripts-library.sh" diff --git a/scripts/scripts-library.sh b/scripts/scripts-library.sh index 0743a2166f..f5b6a6c48e 100755 --- a/scripts/scripts-library.sh +++ b/scripts/scripts-library.sh @@ -92,6 +92,14 @@ function build_ansible_runtime_venv { fi } +# If in OpenStack-Infra, set some vars to use the mirror when bootstrapping Ansible +function load_nodepool_pip_opts { + if [[ -e /etc/ci/mirror_info.sh ]]; then + source /etc/ci/mirror_info.sh + export PIP_OPTS="--index-url ${NODEPOOL_PYPI_MIRROR} --trusted-host ${NODEPOOL_MIRROR_HOST} --extra-index-url ${NODEPOOL_WHEEL_MIRROR}" + fi +} + # Determine the distribution we are running on, so that we can configure it # appropriately. function determine_distro {