Fixes for Azure hostname and swap disk

Signed-off-by: Nathan LeClaire <nathan.leclaire@gmail.com>
This commit is contained in:
Nathan LeClaire 2016-10-06 11:22:23 -07:00
parent 5217107fa4
commit 962f8a4ac9
2 changed files with 29 additions and 10 deletions

View File

@ -10,7 +10,24 @@ start()
{
ebegin "Configuring host block device"
DEV="$(find /dev -maxdepth 1 -type b ! -name 'loop*' | grep -v '[0-9]$' | sed 's@.*/dev/@@' | head -1 )"
# We are being specific with Azure for now. Otherwise the subshell
# below will reference /dev/sdb, which is Azure's "local resource disk"
# (see
# https://blogs.msdn.microsoft.com/mast/2013/12/06/understanding-the-temporary-drive-on-windows-azure-virtual-machines/).
#
# Since attempting to format swap on that disk will cause Azure VHD
# validation to fail, we default to using /dev/sda. requirements
# including not allowing swap partitions.
#
# IMPORTANT: If this, or the root device (/dev/sda1) changes in the
# syslinux / bootloader config for Azure, they will need to be updated
# in parallel.
if [ "$(mobyplatform)" = "azure" ]
then
DEV="sda"
else
DEV="$(find /dev -maxdepth 1 -type b ! -name 'loop*' | grep -v '[0-9]$' | sed 's@.*/dev/@@' | head -1 )"
fi
[ -z "${DEV}" ] && exit 1

View File

@ -13,13 +13,6 @@ start()
[ "$(mobyplatform)" != "azure" ] && exit 0
ebegin "Running Azure-specific initialization"
einfo "Setting hostname"
# TODO: This is probably quite fragile (splitting the returned JSON by
# quotes instead of properly parsing). Would bundling 'jq' in Moby be
# too much overhead?
hostname $(wget -qO- http://169.254.169.254/metadata/v1/instanceinfo | awk -F '"' '{ print $4; }')
for i in $(seq 1 20)
do
einfo "Pulling Windows Azure Linux Agent container"
@ -47,12 +40,15 @@ start()
--ipc host \
--pid host \
--net host \
--uts host \
--restart unless-stopped \
-v /usr/bin/docker:/usr/local/bin/docker:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/log:/var/log \
-v /mnt:/mnt \
-v /home:/home \
-v /etc:/etc \
-v /etc/hostname:/etc/hostname \
-v /lib/modules:/lib/modules \
-v /lib/firmware:/lib/firmware \
-v /var/lib/waagent:/var/lib/waagent \
@ -70,12 +66,18 @@ start()
passwd -u docker
checkpath --directory --mode 0700 /home/docker/.ssh
# Wait for custom data to arrive
while [ ! -f /var/lib/waagent/CustomData ]
# Wait for WALinux agent provisioning to finish before invoking the
# passed custom data. This assures us that hostname etc. is set
# correctly before running, say, swarm commmands.
while [ ! -f /var/lib/waagent/provisioned ]
do
sleep 5
done
# Hack to fix swarm hostname issue. See
# https://github.com/docker/docker/issues/27173
service docker restart
. /var/lib/waagent/CustomData
eend 0