Comment 3 for bug 1686514

Revision history for this message
Stephen A. Zarkos (stevez) wrote :

GPT formatted ephemeral disks have two partitions (unfortunately). The first is the Microsoft reserved partition (https://en.wikipedia.org/wiki/Microsoft_Reserved_Partition). This appears to be tripping up can_dev_be_reformatted().

Function address_ephemeral_resize() will first check if is_new_instance=True, and if so it will happily format the ephemeral disk. That's why this works at first boot.

For subsequent boots where is_new_instance=False, address_ephemeral_resize() will call can_dev_be_reformatted(). This function sees that the ephemeral disk has two partitions and returns false:

            if os.path.exists(devpath + suff + "2"):
                msg = ('device %s had more than 1 partition: %s, %s' %
                       devpath, cand, devpath + suff + "2")
                return False, msg

We also end up with the following TypeError in the logs:

 Traceback (most recent call last):
   File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 647, in status_wrapper
     ret = functor(name, args)
   File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 415, in main_init
     init.activate_datasource()
   File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 369, in activate_datasource
     is_new_instance=self.is_new_instance())
   File "/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceAzure.py", line 251, in activate
     address_ephemeral_resize(is_new_instance=is_new_instance)
   File "/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceAzure.py", line 329, in address_ephemeral_resize
     result, msg = can_dev_be_reformatted(devpath)
   File "/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceAzure.py", line 279, in can_dev_be_reformatted
     devpath, cand, devpath + suff + "2")
 TypeError: not enough arguments for format string
.
.
Aside from the TypeError, even if we comment this part there is a later check to ensure that this partition is NTFS formatted (which it isn't). This will also return false and you will see the following error in the logs:

 "reformattable=False: partition 1 (/dev/disk/cloud/azure_resource-part1 -> /dev/sdb1) on device /dev/disk/cloud/azure_resource was not ntfs formatted"

I think the correct behavior should be for cloud-init to detect that this is a GPT formatted ephemeral disk, or check that azure_resource-part1 is a "Microsoft reserved partition". And if so skip azure_resource-part1 and focus on azure_resource-part2 instead to determine if it is safe to reformat.