From 1503ef327817bd42cbf888e773f5639e660169a7 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 4 Nov 2015 12:09:46 -0500 Subject: [PATCH] warm pip wheel cache during image build This installs everything in upper-constraints in a throw away venv, which has the knock on effect of fully populating the wheel cache for root with wheels for everything. This hopefully speeds up all devstack runs quite a bit. Change-Id: I429f353c33d892f76552c83d34ac1329ed18f97f --- .../install.d/60-pip-warm-cache | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 nodepool/elements/cache-devstack/install.d/60-pip-warm-cache diff --git a/nodepool/elements/cache-devstack/install.d/60-pip-warm-cache b/nodepool/elements/cache-devstack/install.d/60-pip-warm-cache new file mode 100755 index 0000000000..b087bbab04 --- /dev/null +++ b/nodepool/elements/cache-devstack/install.d/60-pip-warm-cache @@ -0,0 +1,48 @@ +#!/bin/bash +# Copyright (C) 2015 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. + +# dib-lint: disable=setpipefail +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu + +REQUIREMENTS_DIR=/opt/git/openstack/requirements +BUILDPIP_VENV=$(mktemp -d) +UC_FILE=$BUILDPIP_VENV/uc.txt + +# Setup venv and install all of the global requirements. This will +# create a warm pip cache which can be used by devstack later. +sudo virtualenv $BUILDPIP_VENV + +# Loop through all possible branches +BRANCHES=`git --git-dir=$REQUIREMENTS_DIR/.git branch -r | grep '^ origin/[^H]'` +for BRANCH in $BRANCHES ; do + git --git-dir=$REQUIREMENTS_DIR/.git show $BRANCH:upper-constraints.txt \ + 2>/dev/null > $UC_FILE || true + if [[ -f $UC_FILE ]]; then + # install all the upper-constraints + sudo -H $BUILDPIP_VENV/bin/pip install -r $UC_FILE + # remove the file at the end to ensure that we don't use an + # old one for this branch + rm -f $UC_FILE + fi +done + +# Delete the venv after the script, we don't care about the venv, just +# the cache artifacts left around. +sudo rm -rf $BUILDPIP_VENV