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.
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"):
devpath, cand, devpath + suff + "2")
return False, msg
msg = ('device %s had more than 1 partition: %s, %s' %
We also end up with the following TypeError in the logs:
Traceback (most recent call last): python3/ dist-packages/ cloudinit/ cmd/main. py", line 647, in status_wrapper python3/ dist-packages/ cloudinit/ cmd/main. py", line 415, in main_init activate_ datasource( ) python3/ dist-packages/ cloudinit/ stages. py", line 369, in activate_datasource new_instance= self.is_ new_instance( )) python3/ dist-packages/ cloudinit/ sources/ DataSourceAzure .py", line 251, in activate ephemeral_ resize( is_new_ instance= is_new_ instance) python3/ dist-packages/ cloudinit/ sources/ DataSourceAzure .py", line 329, in address_ ephemeral_ resize be_reformatted( devpath) python3/ dist-packages/ cloudinit/ sources/ DataSourceAzure .py", line 279, in can_dev_ be_reformatted
File "/usr/lib/
ret = functor(name, args)
File "/usr/lib/
init.
File "/usr/lib/
is_
File "/usr/lib/
address_
File "/usr/lib/
result, msg = can_dev_
File "/usr/lib/
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.