Skip to content

Instantly share code, notes, and snippets.

@paulmey
Last active December 7, 2018 16:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulmey/1a4f35a687d7559dca612a0eda8d5793 to your computer and use it in GitHub Desktop.
Save paulmey/1a4f35a687d7559dca612a0eda8d5793 to your computer and use it in GitHub Desktop.
Repro cloud-init setup_fs bug
#cloud-config
# vim: syntax=yaml
disk_setup:
/dev/sdc:
table_type: gpt
layout: true
overwrite: true
fs_setup:
- label: etcd_disk
filesystem: ext4
device: /dev/sdc1
extra_opts:
- "-F"
- "-E"
- "lazy_itable_init=1,lazy_journal_init=1"
mounts:
- - /dev/sdc1
- /var/lib/etcddisk
--- /usr/lib/python3/dist-packages/cloudinit/util.py 2017-04-03 14:04:43.000000000 +0000
+++ /usr/lib/python3/dist-packages/cloudinit/util.py 2017-05-20 05:03:03.646228392 +0000
@@ -1776,10 +1776,13 @@
sp = subprocess.Popen(args, stdout=stdout,
stderr=stderr, stdin=stdin,
env=env, shell=shell)
(out, err) = sp.communicate(data)
+ LOG.debug("out=%s", out)
+ LOG.debug("err=%s", err)
+ LOG.debug("rc=%d", sp.returncode)
# Just ensure blank instead of none.
if not out and capture:
out = b''
if not err and capture:
--- /usr/lib/python3/dist-packages/cloudinit/config/cc_disk_setup.py 2017-04-03 14:04:43.000000000 +0000
+++ cc_disk_setup.py 2017-05-20 05:04:41.317718710 +0000
@@ -232,16 +232,18 @@
name: the device name, i.e. sda
"""
lsblk_cmd = [LSBLK_CMD, '--pairs', '--output', 'NAME,TYPE,FSTYPE,LABEL',
device]
+ udev_cmd = [UDEVADM_CMD, 'settle']
if nodeps:
lsblk_cmd.append('--nodeps')
info = None
try:
+ util.subp(udev_cmd)
info, _err = util.subp(lsblk_cmd)
except Exception as e:
raise Exception("Failed during disk check for %s\n%s" % (device, e))
parts = [x for x in (info.strip()).splitlines() if len(x.split()) > 0]
#!/bin/bash
[ -n "$rg" ] || ( echo "Set \$rg to the resource group name you want to use" )
echo "Creating VM"
r=$(az group create -n $rg -l westus2)
r=$(az vm create -g $rg --image UbuntuLTS -n testvm -l westus2 --custom-data cloud-config.yml --data-disk-sizes-gb 1023)
ip=$(jq <<< $r '.publicIpAddress' -r)
echo "VM is at $ip"
rm -f .knownhosts
ssh-keyscan $ip > .knownhosts 2>/dev/null
echo "First boot, saving cloud-init log as cloud-init.log.initialboot"
scp -oUserKnownHostsFile=.knownhosts $ip:/var/log/cloud-init.log cloud-init.log.initialboot
ssh -oUserKnownHostsFile=.knownhosts $ip sudo rm /var/log/cloud-init.log
echo " creating file in /var/lib/etcddisk/:"
ssh -oUserKnownHostsFile=.knownhosts $ip sudo touch /var/lib/etcddisk/hello
ssh -oUserKnownHostsFile=.knownhosts $ip ls -al /var/lib/etcddisk/
echo " patching util.py to increase logging of command output"
scp -oUserKnownHostsFile=.knownhosts *.patch $ip:
ssh -oUserKnownHostsFile=.knownhosts $ip sudo patch -p0 -d / <cloudinit_subp_logging.patch
echo " rebooting"
ssh -oUserKnownHostsFile=.knownhosts $ip sudo reboot
sleep 2
time while ! ssh -oUserKnownHostsFile=.knownhosts -oConnectTimeout=1 $ip echo "reboot complete" 2>/dev/null; do true ; done
echo "After first reboot, contents of /var/lib/etcddisk/:"
ssh -oUserKnownHostsFile=.knownhosts $ip ls -al /var/lib/etcddisk/
echo " saving cloud-init log as cloud-init.log.failreboot"
scp -oUserKnownHostsFile=.knownhosts $ip:/var/log/cloud-init.log cloud-init.log.failreboot
ssh -oUserKnownHostsFile=.knownhosts $ip sudo rm /var/log/cloud-init.log
echo " creating file in /var/lib/etcddisk/:"
ssh -oUserKnownHostsFile=.knownhosts $ip sudo touch /var/lib/etcddisk/retry
ssh -oUserKnownHostsFile=.knownhosts $ip ls -al /var/lib/etcddisk/
echo " patching enumerate_disk function"
ssh -oUserKnownHostsFile=.knownhosts $ip sudo patch -p0 -d / <cloudinit_udevsettle_enumerate_disk.patch
echo " rebooting"
ssh -oUserKnownHostsFile=.knownhosts $ip sudo reboot
sleep 2
time while ! ssh -oUserKnownHostsFile=.knownhosts -oConnectTimeout=1 $ip echo "reboot complete" 2>/dev/null; do true ; done
echo "After second reboot, contents of /var/lib/etcddisk/::"
ssh -oUserKnownHostsFile=.knownhosts $ip ls -al /var/lib/etcddisk/
echo " saving cloud-init log as cloud-init.log.successreboot"
scp -oUserKnownHostsFile=.knownhosts $ip:/var/log/cloud-init.log cloud-init.log.successreboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment