diff options
author | Arne Wiebalck <Arne.Wiebalck@cern.ch> | 2021-10-04 16:57:56 +0200 |
---|---|---|
committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2021-10-13 09:26:04 +0000 |
commit | aa2cd29db7574c5e63a9c4194cc58dba089624ad (patch) | |
tree | 4ed76767e12fc65244b48c89706e2a108d592de2 | |
parent | ae1537d9c60403ed4f1b3a728c5e51a5ae68fe1c (diff) | |
download | ironic-python-agent-aa2cd29db7574c5e63a9c4194cc58dba089624ad.tar.gz |
Software RAID: Call udev_settle before creation
This patch fixes a race during software RAID creation:
we create the partition with parted, the kernel then
notifies udev, but we need to wait for udevd to create
the device files before calling mdadm to create the
md device.
Credits to jcosmao for finding this.
Change-Id: I642f28acc351cf50263e37dfbc8468bf59de2cc5
(cherry picked from commit 9d707e9f4bab40109b7e29df2136e86d65325ea3)
-rw-r--r-- | ironic_python_agent/hardware.py | 7 | ||||
-rw-r--r-- | releasenotes/notes/fix-nvme-software-raid-race-2e0e104de9611228.yaml | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index 04426419..d789863f 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -2090,6 +2090,13 @@ class GenericHardwareManager(HardwareManager): utils.execute('parted', device, '-s', '-a', 'optimal', '--', 'mkpart', 'primary', start_str, end_str) + + # Parted/udev partition creation is asynchronous. + # Wait for udev events to be processed before going to + # next step. This avoids getting errors at mdadm + # create because a device is not ready yet. + _udev_settle() + # Necessary, if we want to avoid hitting # an error when creating the mdadm array below # 'mdadm: cannot open /dev/nvme1n1p1: No such file diff --git a/releasenotes/notes/fix-nvme-software-raid-race-2e0e104de9611228.yaml b/releasenotes/notes/fix-nvme-software-raid-race-2e0e104de9611228.yaml new file mode 100644 index 00000000..1a6bfa57 --- /dev/null +++ b/releasenotes/notes/fix-nvme-software-raid-race-2e0e104de9611228.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes a race on software RAID creation: since the creation of + partitions is asynchronous, we need to wait for all udev events + to be processed before we can use the partitions to create an + md device. |