summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-12-19 15:28:55 +0100
committerSimon Rettberg2024-12-19 15:28:55 +0100
commit62a5a6eea9136a74d0db908921810e0c8db9a03d (patch)
tree142106247113f7bcc0873a081016f5e8f9a5af33
parent[slx-watchdog] New module (diff)
downloadsystemd-init-62a5a6eea9136a74d0db908921810e0c8db9a03d.tar.gz
systemd-init-62a5a6eea9136a74d0db908921810e0c8db9a03d.tar.xz
systemd-init-62a5a6eea9136a74d0db908921810e0c8db9a03d.zip
[dnbd3-rootfs] Add hard timeout to udevadm settle
For some reason (to be debugged by a bored person), sometimes "udevadm settle" will hang in a way where it doesn't honor the timeout given via "-t" -- handle this by using SIGKILL after a couple more seconds.
-rwxr-xr-xmodules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh20
1 files changed, 17 insertions, 3 deletions
diff --git a/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh b/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh
index e79938f6..802648d4 100755
--- a/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh
+++ b/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh
@@ -9,6 +9,20 @@ export LD_LIBRARY_PATH="/usr/local/lib"
# hardcode dnbd device path
declare -rg _dnbd3_dev="/dev/dnbd0"
+settle() {
+ if command -v timeout &> /dev/null; then
+ timeout -s 9 15 udevadm settle -t 10
+ else
+ local pid rem
+ udevadm settle -t 10 &
+ pid=$!
+ rem=15
+ while (( --rem > 0 )) && kill -0 "$pid"; do
+ sleep 1
+ done
+ fi >&2
+}
+
# all outputs are redirected to stderr, since this functions should
# only echo the path to the unpacked container to stdout.
container_unpack_raw() {
@@ -18,7 +32,7 @@ container_unpack_raw() {
echo "Failed to attach '$in_device' to '$out_device'."
return 1
fi >&2
- udevadm settle >&2
+ settle
echo "$out_device"
}
@@ -34,7 +48,7 @@ container_unpack_xloop() {
echo "Failed to attach '$in_device' to '$out_device'."
return 1
fi >&2
- udevadm settle >&2
+ settle
echo "$out_device"
}
# endregion
@@ -179,5 +193,5 @@ echo "Using read-only partition: $read_only_partition"
# region add rw layer to dnbd3 image
# don't be fooled to think we are done, the next part is crucial
dmsetup-slx-device "$read_only_partition"
-udevadm settle
+settle
# endregion