~smoser/cloud-utils:fix/growpart-fixes

Last commit made on 2020-05-06
Get this branch:
git clone -b fix/growpart-fixes https://git.launchpad.net/~smoser/cloud-utils
Only Scott Moser can upload to this branch. If you are Scott Moser please log in for upload directions.

Branch merges

Branch information

Name:
fix/growpart-fixes
Repository:
lp:~smoser/cloud-utils

Recent commits

3d6d512... by Scott Moser

growpart: Do not fail if only sgdisk is available.

Previously growpart would fail if sgdisk was available bug sfdisk
was not. This was mostly just because of the order in which support
was added. We never had a scenario where *only* sgdisk was available.

The change here is:
 * effectively cache the value of 'has_cmd sfdisk' or 'has_cmd sgdisk'
   in global variables SFDISK and SGDISK respectively.
 * set SFDISK_VERSION=0 when sfdisk is not available.

630a772... by Scott Moser

growpart: Fix reading sector size with newer sgdisk versions.

sgdisk seems to have changed its output from:
 Logical sector size: <value>
to
 Sector size (logical): <value>

This adds support for reading either one.
If it fails to determine the sector size, it will emit an error
and assume assume 512.

The change came in sgdisk 1.0.2.
In reading code, it will now output one of:

   Sector size (logical/physical): <logical>/<physical> bytes
or
   Sector size (logical): <logical> bytes

d2976bb... by Scott Moser

growpart: Fail on unknown values of GROWPART_RESIZER.

Growpart's selection of sfdisk or sgdisk can be influenced by
the environment variable 'GROWPART_RESIZER', which defaults to 'auto'.

If the value was set to some unknown value, it emit an error message
and effectively use 'auto'. The change here is to fail on unknown
values.

55b089a... by Scott Moser

debian/tests: fix GROWPART_RESIZER value in 'runtests' function.

The 'runtests' function was setting GROWPART_RESIZER to
'gdisk', not 'sgdisk'.

growpart's current behavior is to ignore unknown values. It would
end up just testing sfdisk and passing.

Instead what we do here is
 - fix the value to 'sgdisk'
 - explicitly skip the test for sgdisk/dos

9619a1e... by Scott Moser

cloud-image-utils: Add depends on fdisk, drop e2fsprogs

growpart needs sfdisk or gdisk to work.
sfdisk got split out of util-linux.

e2fsprogs is not needed for cloud-guest-utils.
It is used by resize-part-image, which is part of cloud-image-utils.

LP: #1876139

d99b2d7... by Ryan Harper

growpart: add flock support to prevent udev races

Use an exclusive file lock on the target disk prior to modifying the
partition table to prevent udev scripts from executing while the state
of the partition is being modified. Note that neither sfdisk nor sgdisk
currently take locks on disks and require the use of partx --update to
inform the kernel of changes to mounted partitions. Therefore the locks
must be held across both operations.

See https://systemd.io/BLOCK_DEVICE_LOCKING/ for more information
on udev locking.

LP: #1834875

1691678... by Scott Moser

Drop the python2 only cloud-utils-euca package and tools.

euca2ools is python2 only, so tools that use it are no longer
maintainable. These tools were not specifically dependent on
euca2ools. The user could set EC2PRE='ec2-' and the tools would
then invoke the ec2-api-tool commands rather than their euca-
counterparts.

The same is true of ubuntu-ec2-run, but *it* would default to
ec2- as the prefix by default. However, it has not been maintained
for quite a while. So just remove it also.

LP: #1850257

ef42f6b... by Scott Moser

test-growpart: fix logic error resulting in test failure.

In test-growpart, the cleanup code should unmount if the tracking
variable "MP" has a non-empty value, not an empty value. An empty
value would indicate that the mount has *not* been done.

This is a regression caused by bug 1835124.

LP: #1842682

51ef36d... by Scott Moser

Fix race condition in test-growpart teardown seen on ppc64el.

The test case 'test-growpart' seemed to have a race condition that
would sometimes be seen on the Ubuntu autopkg builder infrastructure.
The failure was only seen on ppc64el.

The fix here is to use 'udevadm settle' liberally in teardown.
I have admittedly not thought this completely through as to what
*could* cause this scenario, and 'udevadm settle' often has the same
effect as 'sleep 1'. That said, this is just in testcase teardown
so there is no harm in making it work even if this is not the fully
"proper" fix.

Also here is removal of code that was not used in test-growpart-fsimage.
There, MP and LODEV were never set, so the removed cleanup would
never run.

LP: #1836593

fadd07f... by Scott Moser

growpart: Fix bug when file image ends in a digit.

If the input to growpart was a file that ended in a digit (my.disk0)
then growing partition would fail because sfdisk output will
uses a 'p' to delimit the filename and partition name.

The fix here is safe/dumb at the cost of a bit of verbosity.

LP: #1835124