balena-io-library / base-images

Balena base images
https://docs.balena.io/reference/base-images/base-images/#balena-base-images
Apache License 2.0
223 stars 85 forks source link

udevadm trigger in entry.sh is broken #670

Open haata opened 3 years ago

haata commented 3 years ago

I've been tracking down a sporadic device issue with debian images. Basically, in entry.sh udevadm trigger is broken.

https://github.com/balena-io-library/base-images/blob/91228b8f7785c025ac662ff38d42b119364ccdfd/balena-base-images/aarch64/debian/bullseye/run/entry.sh#L47

Even though udev has definitely started, systemctl has a check looking to see if we're running in a chroot. This means you'll get something like this:

root@00d8cd4:/app# udevadm trigger
Running in chroot, ignoring request.
root@00d8cd4:/app# echo $?
0

udev is not actually trigger, and devices are not refreshed. Running udevadm trigger from the base BalenaOS works correctly and refreshes devices.

I'm still trying to determine a workaround.

I believe this is the check inside of systemctl/udevadm that exits early: https://cgit.freedesktop.org/systemd/systemd/tree/src/systemctl/systemctl.c#n7476

haata commented 3 years ago

A terrible workaround as future reference.

chroot /proc/1/root
udevadm trigger

This works around this check: https://cgit.freedesktop.org/systemd/systemd/tree/src/basic/util.c#n2171