xenapi: separate disk for cinder volumes

Some kernels have lockup issues while serving cinder volumes from
file-loopback-lvm kind of cinder setup. This patch provides a way to
create an additional drive to the OpenStack VM, and use that to store
cinder volumes, thus eliminating the lockup issue. It will help when
testing XenServer. Now, you can specify devices for stack-volumes
through:

    VOLUME_BACKING_DEVICE

In case you are using CINDER_MULTI_LVM_BACKEND, you can use

    VOLUME_BACKING_DEVICE2

as well.

Xenserver:
Should you whish to use a 10 gig disk backend for your cinder volumes,
specify:

    XEN_XVDB_SIZE_GB=10
    VOLUME_BACKING_DEVICE=/dev/xvdb

Citrix is using this approach on its internal CI system to run tests
against OpenStack. This is a workaround for this bug:

  https://bugs.launchpad.net/cinder/+bug/1023755

Related to blueprint xenapi-devstack-cleanup

Change-Id: Iee633d2704185bfbf9234882654c47b850fa168a
This commit is contained in:
Mate Lakat 2013-06-06 16:22:34 +01:00
parent 04ac51c48b
commit 68ac03c7f2
3 changed files with 45 additions and 13 deletions

View File

@ -69,10 +69,12 @@ CINDER_PERIODIC_INTERVAL=${CINDER_PERIODIC_INTERVAL:-60}
# Name of the lvm volume groups to use/create for iscsi volumes # Name of the lvm volume groups to use/create for iscsi volumes
VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes} VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes}
VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-$DATA_DIR/${VOLUME_GROUP}-backing-file} VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-$DATA_DIR/${VOLUME_GROUP}-backing-file}
VOLUME_BACKING_DEVICE=${VOLUME_BACKING_DEVICE:-}
# VOLUME_GROUP2 is used only if CINDER_MULTI_LVM_BACKEND = True # VOLUME_GROUP2 is used only if CINDER_MULTI_LVM_BACKEND = True
VOLUME_GROUP2=${VOLUME_GROUP2:-stack-volumes2} VOLUME_GROUP2=${VOLUME_GROUP2:-stack-volumes2}
VOLUME_BACKING_FILE2=${VOLUME_BACKING_FILE2:-$DATA_DIR/${VOLUME_GROUP2}-backing-file} VOLUME_BACKING_FILE2=${VOLUME_BACKING_FILE2:-$DATA_DIR/${VOLUME_GROUP2}-backing-file}
VOLUME_BACKING_DEVICE2=${VOLUME_BACKING_DEVICE2:-}
VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-} VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
@ -335,20 +337,24 @@ create_cinder_volume_group() {
# ``/opt/stack/data``. # ``/opt/stack/data``.
if ! sudo vgs $VOLUME_GROUP; then if ! sudo vgs $VOLUME_GROUP; then
if [ -z "$VOLUME_BACKING_DEVICE" ]; then
# Only create if the file doesn't already exists # Only create if the file doesn't already exists
[[ -f $VOLUME_BACKING_FILE ]] || truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE [[ -f $VOLUME_BACKING_FILE ]] || truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE
DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE` DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE`
# Only create if the loopback device doesn't contain $VOLUME_GROUP # Only create if the loopback device doesn't contain $VOLUME_GROUP
if ! sudo vgs $VOLUME_GROUP; then if ! sudo vgs $VOLUME_GROUP; then
sudo vgcreate $VOLUME_GROUP $DEV sudo vgcreate $VOLUME_GROUP $DEV
fi fi
else
sudo vgcreate $VOLUME_GROUP $VOLUME_BACKING_DEVICE
fi
fi fi
if [ "$CINDER_MULTI_LVM_BACKEND" = "True" ]; then if [ "$CINDER_MULTI_LVM_BACKEND" = "True" ]; then
#set up the second volume if CINDER_MULTI_LVM_BACKEND is enabled #set up the second volume if CINDER_MULTI_LVM_BACKEND is enabled
if ! sudo vgs $VOLUME_GROUP2; then if ! sudo vgs $VOLUME_GROUP2; then
if [ -z "$VOLUME_BACKING_DEVICE2" ]; then
# Only create if the file doesn't already exists # Only create if the file doesn't already exists
[[ -f $VOLUME_BACKING_FILE2 ]] || truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE2 [[ -f $VOLUME_BACKING_FILE2 ]] || truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE2
@ -358,6 +364,9 @@ create_cinder_volume_group() {
if ! sudo vgs $VOLUME_GROUP2; then if ! sudo vgs $VOLUME_GROUP2; then
sudo vgcreate $VOLUME_GROUP2 $DEV sudo vgcreate $VOLUME_GROUP2 $DEV
fi fi
else
sudo vgcreate $VOLUME_GROUP2 $VOLUME_BACKING_DEVICE2
fi
fi fi
fi fi

View File

@ -259,6 +259,19 @@ fi
FLAT_NETWORK_BRIDGE=$(bridge_for "$VM_BRIDGE_OR_NET_NAME") FLAT_NETWORK_BRIDGE=$(bridge_for "$VM_BRIDGE_OR_NET_NAME")
append_kernel_cmdline "$GUEST_NAME" "flat_network_bridge=${FLAT_NETWORK_BRIDGE}" append_kernel_cmdline "$GUEST_NAME" "flat_network_bridge=${FLAT_NETWORK_BRIDGE}"
# Add a separate xvdb, if it was requested
if [[ "0" != "$XEN_XVDB_SIZE_GB" ]]; then
vm=$(xe vm-list name-label="$GUEST_NAME" --minimal)
# Add a new disk
localsr=$(get_local_sr)
extra_vdi=$(xe vdi-create \
name-label=xvdb-added-by-devstack \
virtual-size="${XEN_XVDB_SIZE_GB}GiB" \
sr-uuid=$localsr type=user)
xe vbd-create vm-uuid=$vm vdi-uuid=$extra_vdi device=1
fi
# create a snapshot before the first boot # create a snapshot before the first boot
# to allow a quick re-run with the same settings # to allow a quick re-run with the same settings
xe vm-snapshot vm="$GUEST_NAME" new-name-label="$SNAME_FIRST_BOOT" xe vm-snapshot vm="$GUEST_NAME" new-name-label="$SNAME_FIRST_BOOT"

View File

@ -76,4 +76,14 @@ UBUNTU_INST_NAMESERVERS=""
UBUNTU_INST_NETMASK="" UBUNTU_INST_NETMASK=""
UBUNTU_INST_GATEWAY="" UBUNTU_INST_GATEWAY=""
# Create a separate xvdb. Tis could be used as a backing device for cinder
# volumes. Specify
# XEN_XVDB_SIZE_GB=10
# VOLUME_BACKING_DEVICE=/dev/xvdb
# in your localrc to avoid kernel lockups:
# https://bugs.launchpad.net/cinder/+bug/1023755
#
# Set the size to 0 to avoid creation of additional disk.
XEN_XVDB_SIZE_GB=0
source ../../stackrc source ../../stackrc