← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~smoser/cloud-init:bug/1692093-sometimes-need-settle into cloud-init:master

 

Review: Approve

LGTM

Diff comments:

> diff --git a/cloudinit/config/cc_disk_setup.py b/cloudinit/config/cc_disk_setup.py
> index e1505b3..adde1df 100644
> --- a/cloudinit/config/cc_disk_setup.py
> +++ b/cloudinit/config/cc_disk_setup.py
> @@ -737,6 +737,32 @@ def exec_mkpart(table_type, device, layout):
>      return get_dyn_func("exec_mkpart_%s", table_type, device, layout)
>  
>  
> +def udevadm_settle():
> +    util.subp(['udevadm', 'settle'])
> +
> +
> +def assert_and_settle_device(device):
> +    """Assert that device exists and settle so it is fully recognized."""
> +    if not os.path.exists(device):
> +        udevadm_settle()
> +        if not os.path.exists(device):
> +            raise RuntimeError("Device %s did not exist and was not created "
> +                               "with a udevamd settle." % device)
> +
> +    # The device existed, so lets make sure all its partitions
> +    # are created and udev entries read by lsblk updated.
> +    blkdev_cmd = [BLKDEV_CMD, '--rereadpt', device]
> +    try:
> +        util.subp(blkdev_cmd)
> +    except util.ProcessExecutionError as e:
> +        # this can fail legitimately if the device is busy.

# will also fail if `device` is not a full block device

> +        # its possibly busy even as a result of udev events.
> +        LOG.debug("Running blockdev --rereadpt failed (not necessarily "
> +                  "significant): %s", e)
> +
> +    udevadm_settle()
> +
> +
>  def mkpart(device, definition):
>      """
>      Creates the partition table.


-- 
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/324639
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:bug/1692093-sometimes-need-settle into cloud-init:master.


References