From: Adam Israel Date: Thu, 23 Feb 2017 14:36:35 +0000 (+0100) Subject: Accelerating Charm Start X-Git-Tag: v1.1.1~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=736f9e74eee855d77c05482e8a61098cb8b00552;p=osm%2Fdevops.git Accelerating Charm Start - Refactor calls to apt so we only update and install required packages once. - Automatically cache and update the default cloud image - Update model configuration for faster deployment Change-Id: Ic49655585db9fad42c7801f96aa5dd137123b6bf Signed-off-by: Adam Israel --- diff --git a/jenkins/VCA/start_build b/jenkins/VCA/start_build index 186843fc..21d432c5 100755 --- a/jenkins/VCA/start_build +++ b/jenkins/VCA/start_build @@ -12,16 +12,23 @@ # 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. -# +# # 20 Sep 2016 -- Gerardo Garcia -- adapted from template -# +# HERE=$(realpath $(dirname $0)) OSM_JENKINS=$(dirname $HERE) . $OSM_JENKINS/common/all_funcs -INFO "installing packages" -apt update +INFO "Installing packages" +add-apt-repository -y ppa:juju/stable +apt-get update +apt-get install -y juju lxd squid-deb-proxy + +echo 'streams.canonical' > /etc/squid-deb-proxy/mirror-dstdomain.acl.d/20-juju-streams + +INFO "Configuring LXD" +# ZFS doesn't work inside a nested container. ZFS should be configured in the host LXD. lxd init --auto lxd waitready systemctl stop lxd-bridge @@ -47,15 +54,23 @@ EOF systemctl enable lxd-bridge systemctl start lxd-bridge -lxc image copy ubuntu:16.04 local: --alias ubuntu-xenial -add-apt-repository -y ppa:juju/stable -apt update -apt install -y juju -juju bootstrap localhost osm + +INFO "Pre-caching Ubuntu:16.04 image (this may take several minutes)..." + +# Setup a daily cron to update the cached image +cp $HERE/update-lxd-image.sh /etc/cron.daily + +# Run it for the first time +/etc/cron.daily/update-lxd-image.sh xenial + +INFO "Bootstrapping VCA" +juju bootstrap localhost osm \ +--config default-series=xenial \ +--config enable-os-refresh-update=false \ +--config enable-os-upgrade=false \ +--config apt-http-proxy=http://10.44.127.1:8000 RC=0 INFO "done, RC=$RC" exit $RC - - diff --git a/jenkins/VCA/update-lxd-image.sh b/jenkins/VCA/update-lxd-image.sh new file mode 100644 index 00000000..ce14b1dc --- /dev/null +++ b/jenkins/VCA/update-lxd-image.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# This script will create xenial and trusty lxd images that will be used by the +# lxd provider in juju 2.1+ It is for use with the lxd provider for local +# development and preinstalls a common set of production packages. +# +# This dramatically speeds up the install hooks for lxd deploys by +# pre-installing common packages. It is intended to run daily as part of +# a cron job. +set -eux + +# The basic charm layer also installs all the things. 47 packages. +LAYER_BASIC="gcc build-essential python3-pip python3-setuptools python3-yaml" + +# the basic layer also installs virtualenv, but the name changed in xenial. +TRUSTY_PACKAGES="python-virtualenv" +XENIAL_PACKAGES="virtualenv" + +# Predownload common packages used by your charms in development +DOWNLOAD_PACKAGES="" + +PACKAGES="$LAYER_BASIC $DOWNLOAD_PACKAGES" + +function cache() { + series=$1 + container=juju-${series}-base + alias=juju/$series/amd64 + + lxc delete $container -f || true + lxc launch ubuntu:$series $container + sleep 5 # wait for network + + lxc exec $container -- apt-get update -y + lxc exec $container -- apt-get upgrade -y + lxc exec $container -- apt-get install -y $PACKAGES $2 + lxc stop $container + + lxc image delete $alias || true + lxc publish $container --alias $alias description="$series juju dev image ($(date +%Y%m%d))" + + lxc delete $container -f || true +} + +cache trusty "$TRUSTY_PACKAGES" +cache xenial "$XENIAL_PACKAGES"