check_partition_layout has false positives when partitioned with gpt
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
Medium
|
Unassigned | ||
cloud-init (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Xenial |
Fix Released
|
Medium
|
Unassigned | ||
Yakkety |
Fix Released
|
Medium
|
Unassigned | ||
Zesty |
Fix Released
|
Medium
|
Unassigned |
Bug Description
=== Begin SRU Template ===
[Impact]
The disk setup module (disk_setup) of cloud-init had several issues
when dealing with GPT formatted devices. The result was that the user
didn't get expected behavior if they were requesting GPT disk labels
or if the disk present already had a GPT label.
[Test Case]
1.) launch an instance with a second disk "/dev/vdb".
This can be done on openstack or azure.
2.) write a config to system.
$ sudo tee /etc/cloud/
#cloud-config
disk_setup:
/dev/vdb:
table_type: gpt
layout: [66, [33, 82]]
overwrite: True
fs_setup:
- device: /dev/vdb
partition: 1
filesystem: ext4
- device: /dev/vdb
partition: 2
filesystem: swap
mounts:
- ["/dev/vdb1", "/mnt"]
EOF
3. Partition the second disk with a gpt partition table.
download a paritioning tool and use it.
$ wget https:/
# format /dev/vdb with GPT disk label and 2 partitions.
$ sudo LABEL=gpt ./disk-setup ntfs2 /dev/vdb
4. remove state from the instance and reboot. We expect that the desired
partitioning will be done and the mount written and used on reboot.
$ sudo rm -Rf /var/lib/cloud/ /var/log/
$ sudo reboot
5. ssh back in and look around
$ grep vdb /proc/mounts
$ grep mnt /etc/fstab
$ sfdisk -l /dev/vdb
6. sudo reboot
7. ssh back in and look around.
[Regression Potential]
Regressions will be limited to places where the disk_setup module is used.
That is
a.) Azure (by default on new instances or re-deployed instance)
b.) instances with custom user-data or system configuration.
[Other Info]
Upstream commit at
https:/
=== End SRU Template ===
As reported in bug 1686514 (comment 11), there is a bug in the code
that determines if a device layout is "the same" and will thus be re-used.
Even when functional, this code has some serious shortcomings:
a.) it does not check sizes at all, only partition types
b.) it does not check the partition table correctly
The bug to fix here is simply some issues with its usage of sgdisk.
* 'sgdisk -p' was being used to determine the size of a disk.
this can fail if it believes there is a bad gpt partition table.
* parsing of sgdisk -p output assumed that the 'name' of the partition
type would not have any spaces (Microsoft basic data)
* interaction with sgdisk did not realize that sgdisk wants input
of '8300' rather than '83'.
Related bugs:
* bug 1686514: Azure: cloud-init does not handle reformatting GPT partition ephemeral disks
* bug 1691489: fstab entries written by cloud-config may not be mounted
Related branches
- Server Team CI bot: Approve (continuous-integration)
- Ryan Harper: Approve
-
Diff: 151 lines (+46/-36)2 files modifiedcloudinit/config/cc_disk_setup.py (+45/-35)
tests/unittests/test_handler/test_handler_disk_setup.py (+1/-1)
Changed in cloud-init: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
Changed in cloud-init: | |
status: | Confirmed → Fix Committed |
Changed in cloud-init (Ubuntu): | |
status: | New → Fix Released |
importance: | Undecided → Medium |
Changed in cloud-init (Ubuntu Xenial): | |
status: | New → Confirmed |
Changed in cloud-init (Ubuntu Yakkety): | |
status: | New → Confirmed |
Changed in cloud-init (Ubuntu Zesty): | |
status: | New → Confirmed |
Changed in cloud-init (Ubuntu Xenial): | |
importance: | Undecided → Medium |
Changed in cloud-init (Ubuntu Yakkety): | |
importance: | Undecided → Medium |
Changed in cloud-init (Ubuntu Zesty): | |
importance: | Undecided → Medium |
description: | updated |
description: | updated |
Hello Scott, or anyone else affected,
Accepted cloud-init into zesty-proposed. The package will build now and be available at https:/ /launchpad. net/ubuntu/ +source/ cloud-init/ 0.7.9-153- g16a7302f- 0ubuntu1~ 17.04.1 in a few hours, and then in the -proposed repository.
Please help us by testing this new package. See https:/ /wiki.ubuntu. com/Testing/ EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.
If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification- failed. In either case, details of your testing will help us make a better decision.
Further information regarding the verification process can be found at https:/ /wiki.ubuntu. com/QATeam/ PerformingSRUVe rification . Thank you in advance!