Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Configure dmsetup to fallback to managing device nodes without udevd #654

Merged
merged 3 commits into from
Aug 10, 2020

Conversation

stealthybox
Copy link
Contributor

This patch frees up dependent interactions with udev for device node creation.
Ignite can now create boot devices in absence of a working udevd equivalent.
This makes ignite easier to run in docker containers and WSL2.

I wrote a similar implementation (no_udev_sync) which completely bypassed udev sync even when present.
It execs dmsetup info to retrieve block device paths and manages its own symlinks, but I found this implementation gets sort of coupled to /dev in the root mount namespace because dmsetup info will return the canonical device-path of /dev/dm-$i.
It's simple and possible to call mknod /dev/dm-$i -m600 253 $i and ensure the device node exists with no_udev_sync.

I decided to try using the built-in udev fallback from dmsetup which is what is implemented in this PR.

Note it's possible to actually get working behavior with older builds of ignite by setting DM_DISABLE_UDEV=1, but this requires the user to know about udev and potentially passthrough their env to sudo.

I found in dmsetup's changelog that the --verifyudev fallback actually used to be the default behavior.
I didn't look further, but I assume this was disabled, because it could be potentially harmful if you created devices during boot before udevd started up.
I figure that silently having udev rules not apply is fairly low-risk for ignite boot devices -- if people are using ignite during boot, they should be configuring their units at the proper run-level, but it is a consideration.
The trade-off is that if we accept this bit of informal fallback behavior, users don't have to configure dmsetup, and ignite can use dmsetup in containers without mounting /dev:/dev*.

Note: losetup does not seem to currently have any device node management.
In order for losetup to work in a container without mounting /dev:/dev you need to pre-create some loop device nodes in the container like so:

for i in {0..20}; do mknod /dev/loop$i -m600 b 7 $i; done

Other Changes:

  • Fix DeactivateSnapshot bug which would cause cleanup failures
  • Refactor ActivateSnapshot to return snapshotDevPath so it is just calculated once

This patch frees up dependent interactions with udev for device node creation.
Ignite can now create boot devices in absence of a working udevd equivalent.
This makes ignite easier to run in docker containers and WSL2.
@stealthybox stealthybox added area/dependency Issues or PRs related to dependency changes area/runtime Issues related to container runtimes kind/enhancement Categorizes issue or PR as related to improving an existing feature. kind/refactor Categorizes issue or PR as related to refactoring code. labels Aug 5, 2020
Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Great improvements. Will be fun to run in container 🙂

@stealthybox stealthybox merged commit 572e89a into weaveworks:master Aug 10, 2020
@stealthybox stealthybox deleted the verify-udev branch August 10, 2020 16:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/dependency Issues or PRs related to dependency changes area/runtime Issues related to container runtimes kind/enhancement Categorizes issue or PR as related to improving an existing feature. kind/refactor Categorizes issue or PR as related to refactoring code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants