Skip gate FS optimization if no secondary disk

This commit removes the assumption that all gate nodes have a secondary
disk, and skip tuning the filesystem if the node doesn't have one.

This fixes gate failures on OVH nodes.

Closes-Bug: #1525047

Change-Id: Ief22f34b32caf7a8b446df888fc5cc1964ad272e
(cherry picked from commit 40b8a0243e)
This commit is contained in:
Martin André 2015-12-11 11:11:05 +09:00
parent 19621ff977
commit 0c6d5e60ed
2 changed files with 39 additions and 32 deletions

View File

@ -14,25 +14,28 @@ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58
sudo apt-get update sudo apt-get update
sudo apt-get install -y --no-install-recommends docker-engine=1.8.2-0~trusty btrfs-tools sudo apt-get install -y --no-install-recommends docker-engine=1.8.2-0~trusty btrfs-tools
# The reason for using BTRFS is stability. There are numerous issues with the # Only do FS optimization if we have a secondary disk
# devicemapper backed on Ubuntu and AUFS is slow. BTRFS is very solid as a if [[ -b /dev/${DEV} ]]; then
# backend in my experince. I use ie almost exclusively. # The reason for using BTRFS is stability. There are numerous issues with the
# Format Disks and setup Docker to use BTRFS # devicemapper backed on Ubuntu and AUFS is slow. BTRFS is very solid as a
sudo umount /dev/${DEV} || true # backend in my experince. I use ie almost exclusively.
sudo parted /dev/${DEV} -s -- mklabel msdos # Format Disks and setup Docker to use BTRFS
sudo service docker stop sudo umount /dev/${DEV} || true
echo 'DOCKER_OPTS="-s btrfs"' | sudo tee /etc/default/docker sudo parted /dev/${DEV} -s -- mklabel msdos
sudo rm -rf /var/lib/docker/* sudo service docker stop
echo 'DOCKER_OPTS="-s btrfs"' | sudo tee /etc/default/docker
sudo rm -rf /var/lib/docker/*
# We want to snapshot the entire docker directory so we have to first create a # We want to snapshot the entire docker directory so we have to first create a
# subvolume and use that as the root for the docker directory. # subvolume and use that as the root for the docker directory.
sudo mkfs.btrfs -f /dev/${DEV} sudo mkfs.btrfs -f /dev/${DEV}
sudo mount /dev/${DEV} /var/lib/docker sudo mount /dev/${DEV} /var/lib/docker
sudo btrfs subvolume create /var/lib/docker/docker sudo btrfs subvolume create /var/lib/docker/docker
sudo umount /var/lib/docker sudo umount /var/lib/docker
sudo mount -o noatime,compress=lzo,space_cache,subvol=docker /dev/${DEV} /var/lib/docker sudo mount -o noatime,compress=lzo,space_cache,subvol=docker /dev/${DEV} /var/lib/docker
sudo service docker start sudo service docker start
fi
sudo docker info sudo docker info

View File

@ -19,22 +19,26 @@ EOF
sudo yum install -y libffi-devel openssl-devel docker-engine-1.8.2 xfsprogs sudo yum install -y libffi-devel openssl-devel docker-engine-1.8.2 xfsprogs
# Setup backing disk for use with Docker. This is to ensure we use the ephemeral # Only do FS optimization if we have a secondary disk
# disk provided to the build instance. It ensures the correct disk and storage if [[ -b /dev/${DEV} ]]; then
# driver are used for Docker. It is recommend to use the thin provisioning # Setup backing disk for use with Docker. This is to ensure we use the ephemeral
# driver. https://github.com/docker/docker/blob/master/man/docker.1.md # disk provided to the build instance. It ensures the correct disk and storage
sudo parted /dev/${DEV} -s -- mklabel msdos mkpart pri 1 -1 # driver are used for Docker. It is recommend to use the thin provisioning
# Figure out the path to the partitioned device # driver. https://github.com/docker/docker/blob/master/man/docker.1.md
PARTDEV=$(ls "/dev/${DEV}"* | egrep "/dev/${DEV}p?1") sudo parted /dev/${DEV} -s -- mklabel msdos mkpart pri 1 -1
sudo pvcreate ${PARTDEV} # Figure out the path to the partitioned device
sudo vgcreate kolla01 ${PARTDEV} PARTDEV=$(ls "/dev/${DEV}"* | egrep "/dev/${DEV}p?1")
sudo lvcreate -n thin01 -L 60G kolla01 sudo pvcreate ${PARTDEV}
sudo lvcreate -n thin01meta -L 2G kolla01 sudo vgcreate kolla01 ${PARTDEV}
yes | sudo lvconvert --type thin-pool --poolmetadata kolla01/thin01meta kolla01/thin01 sudo lvcreate -n thin01 -L 60G kolla01
sudo lvcreate -n thin01meta -L 2G kolla01
yes | sudo lvconvert --type thin-pool --poolmetadata kolla01/thin01meta kolla01/thin01
# Setup Docker
sudo sed -i -r 's,(ExecStart)=(.+),\1=/usr/bin/docker daemon --storage-driver devicemapper --storage-opt dm.fs=xfs --storage-opt dm.thinpooldev=kolla01-thin01 --storage-opt dm.use_deferred_removal=true,' /usr/lib/systemd/system/docker.service
sudo systemctl daemon-reload
fi
# Setup Docker
sudo sed -i -r 's,(ExecStart)=(.+),\1=/usr/bin/docker daemon --storage-driver devicemapper --storage-opt dm.fs=xfs --storage-opt dm.thinpooldev=kolla01-thin01 --storage-opt dm.use_deferred_removal=true,' /usr/lib/systemd/system/docker.service
sudo systemctl daemon-reload
sudo systemctl start docker sudo systemctl start docker
sudo docker info sudo docker info