Change:
On AWS we (will) now run our bootstrap script on every boot. The function to initialize ephemeral volumes doesn't tolerate being re-run, and we probably shouldn't re-run it anyway for speed. This does preserve the contents, which may be a good thing to save user's data (it doesn't belong on ephemeral drives, but...). On the other hand, if the ephemeral drives are corrupted, we lose the opportunity to reformat them and recover. Arguably, if the ephemeral storage is corrupted the right thing to do is to terminate the instance entirely.

Discussion:
function ensure-local-disks() { <ins> # Skip if already mounted (a reboot) if ( grep "/mnt/ephemeral" /proc/mounts ); then echo "Found /mnt/ephemeral in /proc/mounts; skipping local disk initialization" return fi </ins> block_devices=() ephemeral_devices=$(curl --silent http://169.254.169.254/2014-11-05/meta-data/block-device-mapping/ | grep ephemeral)

# Remove any existing mounts for block_device in ${block_devices}; do echo "Unmounting ${block_device}" <del> /bin/umount ${block_device} </del> <ins> /bin/umount ${block_device} || echo "Ignoring failure umounting ${block_device}" </ins> sed -i -e "|^${block_device}|d" /etc/fstab done <ins> # Remove any existing /mnt/ephemeral entry in /etc/fstab sed -i -e "|/mnt/ephemeral|d" /etc/fstab # Mount the storage </ins> if [[ ${docker_storage} == "btrfs" ]]; then apt-get-install btrfs-tools

echo "Found multiple ephemeral block devices, formatting with btrfs as RAID-0" mkfs.btrfs -f --data raid0 ${block_devices[@]} fi <del> echo "${block_devices[0]}  /mnt/ephemeral  btrfs  noatime  0 0" >> /etc/fstab </del> <ins> echo "${block_devices[0]}  /mnt/ephemeral  btrfs  noatime,nofail  0 0" >> /etc/fstab </ins> mkdir -p /mnt/ephemeral mount /mnt/ephemeral

fi mkfs -t ext4 ${block_devices[0]} <del> echo "${block_devices[0]}  /mnt/ephemeral  ext4     noatime  0 0" >> /etc/fstab </del> <ins> echo "${block_devices[0]}  /mnt/ephemeral  ext4     noatime,nofail  0 0" >> /etc/fstab </ins> mkdir -p /mnt/ephemeral mount /mnt/ephemeral

lvcreate -l 100%FREE -n kubernetes vg-ephemeral mkfs -t ext4 /dev/vg-ephemeral/kubernetes mkdir -p /mnt/ephemeral/kubernetes <del> echo "/dev/vg-ephemeral/kubernetes  /mnt/ephemeral/kubernetes  ext4  noatime  0 0" >> /etc/fstab </del> <ins> echo "/dev/vg-ephemeral/kubernetes  /mnt/ephemeral/kubernetes  ext4  noatime,nofail  0 0" >> /etc/fstab </ins> mount /mnt/ephemeral/kubernetes move_kubelet="/mnt/ephemeral/kubernetes"

lvcreate -l 100%VG -n ephemeral vg-ephemeral mkfs -t ext4 /dev/vg-ephemeral/ephemeral mkdir -p /mnt/ephemeral <del> echo "/dev/vg-ephemeral/ephemeral  /mnt/ephemeral  ext4  noatime  0 0" >> /etc/fstab </del> <ins> echo "/dev/vg-ephemeral/ephemeral  /mnt/ephemeral  ext4  noatime,nofail 0 0" >> /etc/fstab </ins> mount /mnt/ephemeral mkdir -p /mnt/ephemeral/kubernetes

if [[ -n "${move_docker}" ]]; then # Move docker to e.g. /mnt <ins> # but only if it is a directory, not a symlink left over from a previous run </ins> if [[ -d /var/lib/docker ]]; then mv /var/lib/docker ${move_docker}/ fi mkdir -p ${move_docker}/docker <del> ln -s ${move_docker}/docker /var/lib/docker </del> <ins> # If /var/lib/docker doesn't exist (it will exist if it is already a symlink), # then symlink it to the ephemeral docker area if [[ ! -e /var/lib/docker ]]; then ln -s ${move_docker}/docker /var/lib/docker fi </ins> DOCKER_ROOT="${move_docker}/docker" DOCKER_OPTS="${DOCKER_OPTS:-} -g ${DOCKER_ROOT}" fi

if [[ -n "${move_kubelet}" ]]; then # Move /var/lib/kubelet to e.g. /mnt # (the backing for empty-dir volumes can use a lot of space!) <ins> # (As with /var/lib/docker, only if it is a directory; skip if symlink) </ins> if [[ -d /var/lib/kubelet ]]; then mv /var/lib/kubelet ${move_kubelet}/ fi mkdir -p ${move_kubelet}/kubelet <del> ln -s ${move_kubelet}/kubelet /var/lib/kubelet </del> <ins> # Create symlink for /var/lib/kubelet, unless it is already a symlink if [[ ! -e /var/lib/kubelet ]]; then ln -s ${move_kubelet}/kubelet /var/lib/kubelet fi </ins> KUBELET_ROOT="${move_kubelet}/kubelet" fi