setup-storage: wait for LV device node before using it#139
Open
insatomcat wants to merge 1 commit into
Open
Conversation
After lvcreate returns, the kernel has created the underlying /dev/dm-N device, but the friendly-name symlinks /dev/<vg>/<lv> (and /dev/mapper/<vg>-<lv>) are only created asynchronously once udev processes the corresponding uevent. setup-storage already calls "udevadm settle" before every command, but that relies on a reachable, responsive udev daemon and can return prematurely or be a no-op when udev is slow or unreachable -- e.g. in privileged containers sharing the host's /dev (see rancher/os#838) -- which leads to intermittent "mkfs.ext4: No such file or directory" failures. Add wait_for_device(), a small bounded poll loop for the device node itself, and slot it into the LV creation command chain between lvcreate and anything that consumes /dev/<vg>/<lv> (mkfs, resize, ...). This is environment-agnostic and catches the case where udevadm settle alone is not sufficient.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After lvcreate returns, the kernel has created the underlying
/dev/dm-Ndevice, but the friendly-name symlinks/dev/<vg>/<lv>(and/dev/mapper/<vg>-<lv>) are only created asynchronously once udev processes the corresponding uevent. setup-storage already calls "udevadm settle" before every command, but that relies on a reachable, responsive udev daemon and can return prematurely or be a no-op when udev is slow or unreachable -- e.g. in privileged containers sharing the host's /dev (see rancher/os#838) -- which leads to intermittent "mkfs.ext4: No such file or directory" failures.Add wait_for_device(), a small bounded poll loop for the device node itself, and slot it into the LV creation command chain between lvcreate and anything that consumes /
dev/<vg>/<lv>(mkfs, resize, ...). This is environment-agnostic and catches the case where udevadm settle alone is not sufficient.