Change AIO bootstrap disk preparation

This implements a change in the AIO disk preparation in the hope that
it will result in less Gate failures (due to the OS disk running low)
and will increase the flexibility slightly for dev/test purposes.

This introduces the following new environment variables:

 - BOOTSTRAP_AIO_DIR
   A data directory for the AIO's loopback disks. This was previously
   hard coded to '/opt' and is now set to '/openstack'.
 - DATA_DISK_DEVICE
   If there is a large enough secondary disk available, the bootstrap
   script will repartition it, format it and mount it at
   BOOTSTRAP_AIO_DIR.
   If you wish to specify which disk to use, then this var may be set.

This also changes the following environment variable:
 - MIN_LXC_VG_SIZE_GB -> MIN_DISK_SIZE_GB
   This represents the smallest disk size required (in GB) which may
   be repurposed by the bootstrap script. This size is set to 80G by
   default.

This patch also makes some minor optimisations in some of the grep
statements relating to the loopback disks and moves some of the gate
check script actions to accommodate the reparitioning of /openstack
which is where the gate check logs are held.

The new process implements the following major changes:

 - The BOOTSTRAP_AIO_DIR contains the loopback disks for
   cinder-volume, swift, swap and nova.
 - /var/lib/lxc will always be a normal ext4 partition - it used to
   be done this way in RAX Cloud and setup as a LVM VG in HP Cloud.
 - LXC containers will always use sparse files, unless the end-user
   sets up their own lxc vg.
 - The nova instances will now be built onto a sparse loopback disk
   mounted at /var/lib/nova/instances. This is specifically due to
   issues with that directory being on the root disk for gate tests
   and the root disks are too small to support instance creation.
 - The /openstack directory will be setup as a partition on the
   second disk. As this directory holds variable data this is deemend
   more appropriate for long running AIO testing and development.

Implements: blueprint gate-split
Change-Id: I96b0c787ed4b6bb01a629a7899bea581fb39be4f
This commit is contained in:
Jesse Pretorius 2015-11-25 15:46:19 +00:00
parent 30963fe490
commit 3a31ac6af5
3 changed files with 103 additions and 68 deletions

View File

@ -21,6 +21,7 @@ set -e -u -x
## Vars ----------------------------------------------------------------------
DEFAULT_PASSWORD=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 32)
export BOOTSTRAP_AIO="yes"
export BOOTSTRAP_AIO_DIR=${BOOTSTRAP_AIO_DIR:-"/openstack"}
export HTTP_PROXY=${HTTP_PROXY:-""}
export HTTPS_PROXY=${HTTPS_PROXY:-""}
export ADMIN_PASSWORD=${ADMIN_PASSWORD:-$DEFAULT_PASSWORD}
@ -140,9 +141,9 @@ else
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
fi
# Create /opt if it doesn't already exist
if [ ! -d "/opt" ];then
mkdir /opt
# Create the directory BOOTSTRAP_AIO_DIR if it doesn't already exist
if [ ! -d "${BOOTSTRAP_AIO_DIR}" ]; then
mkdir -p ${BOOTSTRAP_AIO_DIR}
fi
# Remove the pip directory if its found
@ -194,7 +195,7 @@ if [ ! "$(swapon -s | grep -v Filename)" ]; then
else
swap_size="8589934592"
fi
loopback_create "/opt/swap.img" ${swap_size} thick swap
loopback_create "${BOOTSTRAP_AIO_DIR}/swap.img" ${swap_size} thick swap
# Ensure swap will be used on the host
if [ ! $(sysctl vm.swappiness | awk '{print $3}') == "10" ];then
sysctl -w vm.swappiness=10 | tee -a /etc/sysctl.conf
@ -206,7 +207,7 @@ if [ "${DEPLOY_OPENSTACK}" == "yes" ]; then
# Build the loopback drive for cinder to use
CINDER="cinder.img"
if ! vgs cinder-volumes; then
loopback_create "/opt/${CINDER}" 1073741824000 thin rc
loopback_create "${BOOTSTRAP_AIO_DIR}/${CINDER}" 1073741824000 thin rc
CINDER_DEVICE=$(losetup -a | awk -F: "/${CINDER}/ {print \$1}")
pvcreate ${CINDER_DEVICE}
pvscan
@ -216,24 +217,36 @@ if [ "${DEPLOY_OPENSTACK}" == "yes" ]; then
fi
# Ensure that the cinder loopback is enabled after reboot
if ! grep ${CINDER} /etc/rc.local && ! vgs cinder-volumes; then
sed -i "\$i losetup \$(losetup -f) /opt/${CINDER}" /etc/rc.local
sed -i "\$i losetup \$(losetup -f) /${BOOTSTRAP_AIO_DIR}/${CINDER}" /etc/rc.local
fi
fi
# Build the loopback drive for nova instance storage
NOVA="nova.img"
if ! grep -q "${NOVA}" /proc/mounts; then
loopback_create "${BOOTSTRAP_AIO_DIR}/${NOVA}" 1073741824000 thin none
mkfs.ext4 -F "${BOOTSTRAP_AIO_DIR}/${NOVA}"
mkdir -p /var/lib/nova/instances
mount "${BOOTSTRAP_AIO_DIR}/${NOVA}" /var/lib/nova/instances
fi
if ! grep -qw "^${BOOTSTRAP_AIO_DIR}/${NOVA}" /etc/fstab; then
echo "${BOOTSTRAP_AIO_DIR}/${NOVA} /var/lib/nova/instances ext4 defaults 0 0" >> /etc/fstab
fi
fi
# Enable swift deployment
if [ "${DEPLOY_SWIFT}" == "yes" ]; then
# build the loopback drives for swift to use
for SWIFT in swift1 swift2 swift3; do
if ! grep "${SWIFT}" /proc/mounts > /dev/null; then
loopback_create "/opt/${SWIFT}.img" 1073741824000 thin none
if ! grep -w "^/opt/${SWIFT}.img" /etc/fstab > /dev/null; then
echo "/opt/${SWIFT}.img /srv/${SWIFT}.img xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab
if ! grep -q "${SWIFT}" /proc/mounts; then
loopback_create "${BOOTSTRAP_AIO_DIR}/${SWIFT}.img" 1073741824000 thin none
if ! grep -qw "^${BOOTSTRAP_AIO_DIR}/${SWIFT}.img" /etc/fstab; then
echo "${BOOTSTRAP_AIO_DIR}/${SWIFT}.img /srv/${SWIFT}.img xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab
fi
# Format the lo devices
mkfs.xfs -f "/opt/${SWIFT}.img"
mkfs.xfs -f "${BOOTSTRAP_AIO_DIR}/${SWIFT}.img"
mkdir -p "/srv/${SWIFT}.img"
mount "/opt/${SWIFT}.img" "/srv/${SWIFT}.img"
mount "${BOOTSTRAP_AIO_DIR}/${SWIFT}.img" "/srv/${SWIFT}.img"
fi
done
fi

View File

@ -42,19 +42,6 @@ info_block "Checking for required libraries." 2> /dev/null || source $(dirname $
## Main ----------------------------------------------------------------------
# Disable Ansible color output
sed -i 's/nocolor.*/nocolor = 1/' $(dirname ${0})/../playbooks/ansible.cfg
# Make the /openstack/log directory for openstack-infra gate check log publishing
mkdir -p /openstack/log
# Implement the log directory link for openstack-infra log publishing
ln -sf /openstack/log $(dirname ${0})/../logs
# Create ansible logging directory and add in a log file entry into ansible.cfg
mkdir -p /openstack/log/ansible-logging
sed -i '/\[defaults\]/a log_path = /openstack/log/ansible-logging/ansible.log' $(dirname ${0})/../playbooks/ansible.cfg
# Adjust settings based on the Cloud Provider info in OpenStack-CI
if [ -f /etc/nodepool/provider -a -s /etc/nodepool/provider ]; then
source /etc/nodepool/provider
@ -82,9 +69,6 @@ if [ -f /etc/nodepool/provider -a -s /etc/nodepool/provider ]; then
fi
# Enable detailed task profiling
sed -i '/\[defaults\]/a callback_plugins = plugins/callbacks' $(dirname ${0})/../playbooks/ansible.cfg
# Bootstrap an AIO setup if required
if [ "${BOOTSTRAP_AIO}" == "yes" ]; then
source $(dirname ${0})/bootstrap-aio.sh
@ -95,6 +79,22 @@ if [ "${BOOTSTRAP_ANSIBLE}" == "yes" ]; then
source $(dirname ${0})/bootstrap-ansible.sh
fi
# Make the /openstack/log directory for openstack-infra gate check log publishing
mkdir -p /openstack/log
# Implement the log directory link for openstack-infra log publishing
ln -sf /openstack/log $(dirname ${0})/../logs
# Create ansible logging directory and add in a log file entry into ansible.cfg
mkdir -p /openstack/log/ansible-logging
sed -i '/\[defaults\]/a log_path = /openstack/log/ansible-logging/ansible.log' $(dirname ${0})/../playbooks/ansible.cfg
# Enable detailed task profiling
sed -i '/\[defaults\]/a callback_plugins = plugins/callbacks' $(dirname ${0})/../playbooks/ansible.cfg
# Disable Ansible color output
sed -i 's/nocolor.*/nocolor = 1/' $(dirname ${0})/../playbooks/ansible.cfg
# Enable debug logging for all services to make failure debugging easier
echo "debug: True" | tee -a /etc/openstack_deploy/user_variables.yml

View File

@ -18,7 +18,9 @@
## Vars ----------------------------------------------------------------------
LINE='----------------------------------------------------------------------'
MAX_RETRIES=${MAX_RETRIES:-5}
MIN_LXC_VG_SIZE_GB=${MIN_LXC_VG_SIZE_GB:-250}
BOOTSTRAP_AIO_DIR=${BOOTSTRAP_AIO_DIR:-"/openstack"}
DATA_DISK_DEVICE=${DATA_DISK_DEVICE:-}
MIN_DISK_SIZE_GB=${MIN_DISK_SIZE_GB:-80}
REPORT_DATA=${REPORT_DATA:-""}
ANSIBLE_PARAMETERS=${ANSIBLE_PARAMETERS:-""}
STARTTIME="${STARTTIME:-$(date +%s)}"
@ -77,48 +79,68 @@ function install_bits {
function configure_diskspace {
# If there are any block devices available other than the one
# used for the root disk, repurpose it for our needs.
MIN_LXC_VG_SIZE_B=$((MIN_LXC_VG_SIZE_GB * 1024 * 1024 * 1024))
# only do this if the lxc vg doesn't already exist
if ! vgs lxc > /dev/null 2>&1; then
blk_devices=$(lsblk -nrdo NAME,TYPE,RO | awk '/d[b-z]+ disk [^1]/ {print $1}')
for blk_dev in ${blk_devices}; do
# dismount any mount points on the device
mount_points=$(awk "/^\/dev\/${blk_dev}[0-9]* / {print \$2}" /proc/mounts)
for mount_point in ${mount_points}; do
umount ${mount_point}
sed -i ":${mount_point}:d" /etc/fstab
done
# If DATA_DISK_DEVICE is not set or empty, then try to figure out which
# device to use
if [ -z "${DATA_DISK_DEVICE}" ]; then
# Identify the list of disk devices available, sort from largest to
# smallest, and pick the largest.
# Excludes:
# - the first device, as that is where the OS is expected
# - read only devices, as we can't write to them
DATA_DISK_DEVICE=$(lsblk -brndo NAME,TYPE,RO,SIZE | \
awk '/d[b-z]+ disk 0/{ if ($4>m){m=$4; d=$1}}; END{print d}')
fi
# We only want to continue if a device was found to use. If not,
# then we simply leave the disks alone.
if [ ! -z "${DATA_DISK_DEVICE}" ]; then
# Calculate the minimum disk size in bytes
MIN_DISK_SIZE_B=$((MIN_DISK_SIZE_GB * 1024 * 1024 * 1024))
# Determine the size in bytes of the selected device
blk_dev_size_b=$(lsblk -nrdbo NAME,TYPE,SIZE | \
awk "/^${DATA_DISK_DEVICE} disk/ {print \$3}")
# Determine if the device is large enough
if [ "${blk_dev_size_b}" -ge "${MIN_DISK_SIZE_B}" ]; then
# Only execute the disk partitioning process if a partition labeled
# 'openstack-data{1,2}' is not present and that partition is not
# formatted as ext4. This is an attempt to achieve idempotency just
# in case this script is run multiple times.
if ! parted --script -l -m | egrep -q ':ext4:openstack-data[12]:;$'; then
# Dismount any mount points on the device
mount_points=$(awk "/^\/dev\/${DATA_DISK_DEVICE}[0-9]* / {print \$2}" /proc/mounts)
for mount_point in ${mount_points}; do
umount ${mount_point}
sed -i ":${mount_point}:d" /etc/fstab
done
# Partition the whole disk for our usage
parted --script /dev/${DATA_DISK_DEVICE} mklabel gpt
parted --align optimal --script /dev/${DATA_DISK_DEVICE} mkpart openstack-data1 ext4 0% 40%
parted --align optimal --script /dev/${DATA_DISK_DEVICE} mkpart openstack-data2 ext4 40% 100%
# Format the bootstrap partition, create the mount point, and mount it.
mkfs.ext4 /dev/${DATA_DISK_DEVICE}1
mkdir -p ${BOOTSTRAP_AIO_DIR}
mount /dev/${DATA_DISK_DEVICE}1 ${BOOTSTRAP_AIO_DIR}
# Format the lxc partition, create the mount point, and mount it.
mkfs.ext4 /dev/${DATA_DISK_DEVICE}2
mkdir -p /var/lib/lxc
mount /dev/${DATA_DISK_DEVICE}2 /var/lib/lxc
# add a vg for lxc
blk_dev_size_b=$(lsblk -nrdbo NAME,TYPE,SIZE | awk "/^${blk_dev} disk/ {print \$3}")
if [ "${blk_dev_size_b}" -gt "${MIN_LXC_VG_SIZE_B}" ]; then
if ! vgs lxc > /dev/null 2>&1; then
parted --script /dev/${blk_dev} mklabel gpt
parted --align optimal --script /dev/${blk_dev} mkpart lxc 0% 80%
part_num=$(parted /dev/${blk_dev} print --machine | awk -F':' '/lxc/ {print $1}')
pvcreate -ff -y /dev/${blk_dev}${part_num}
vgcreate lxc /dev/${blk_dev}${part_num}
fi
# add a vg for cinder volumes, but only if it doesn't already exist
if ! vgs cinder-volumes > /dev/null 2>&1; then
parted --align optimal --script /dev/${blk_dev} mkpart cinder 80% 100%
part_num=$(parted /dev/${blk_dev} print --machine | awk -F':' '/cinder/ {print $1}')
pvcreate -ff -y /dev/${blk_dev}${part_num}
vgcreate cinder-volumes /dev/${blk_dev}${part_num}
fi
else
if ! grep '/var/lib/lxc' /proc/mounts 2>&1; then
parted --script /dev/${blk_dev} mklabel gpt
parted --script /dev/${blk_dev} mkpart lxc ext4 0% 100%
part_num=$(parted /dev/${blk_dev} print --machine | awk -F':' '/lxc/ {print $1}')
# Format, Create, and Mount it all up.
mkfs.ext4 /dev/${blk_dev}${part_num}
mkdir -p /var/lib/lxc
mount /dev/${blk_dev}${part_num} /var/lib/lxc
fi
fi
done
# Add the fstab entries if they aren't there already
if ! grep -qw "^/dev/${DATA_DISK_DEVICE}1" /etc/fstab; then
echo "/dev/${DATA_DISK_DEVICE}1 ${BOOTSTRAP_AIO_DIR} ext4 defaults 0 0" >> /etc/fstab
fi
if ! grep -qw "^/dev/${DATA_DISK_DEVICE}2" /etc/fstab; then
echo "/dev/${DATA_DISK_DEVICE}2 /var/lib/lxc ext4 defaults 0 0" >> /etc/fstab
fi
fi
fi
}