← 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

 


Diff comments:

> diff --git a/cloudinit/config/cc_disk_setup.py b/cloudinit/config/cc_disk_setup.py
> index e1505b3..7aacae4 100644
> --- a/cloudinit/config/cc_disk_setup.py
> +++ b/cloudinit/config/cc_disk_setup.py
> @@ -737,6 +737,21 @@ 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)
> +
> +    udevadm_settle()

The problem originally reported was that we were/are using lsblk to list partitions on a disk.
Paul correctly identifed that lsblk relies on udev attributes (
 https://code.launchpad.net/~paul-meyer/cloud-init/+git/cloud-init/+merge/324359/comments/850354)
And his logs clearly show lsdev getting incorrect information out of those atributes.

This is what originally made me put in a 'blockdev --reread'.  Was to make sure an event was created that would cause udev to scan the devices for filesystem information and such.

Either way, it is definitely possible that the device exists but that there are still events in flight that would populate udev's database. The settle here is to make sure those are done.

> +
> +
>  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