Skip to content

Commit d63d12a

Browse files
authored
Merge pull request #4377 from flatcar/chewi/sysext-udev
Fix zfs sysext by triggering udev when sysext includes udev rules
2 parents 8d3c008 + 62e290c commit d63d12a

4 files changed

Lines changed: 377 additions & 7 deletions

File tree

‎build_library/sysext_mangle_flatcar-zfs‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,8 @@ d /etc/zfs 0755 root root -
3535
L /etc/zfs/zed.d - - - - /usr/share/zfs/etc/zfs/zed.d
3636
L /etc/zfs/zfs-functions - - - - /usr/share/zfs/etc/zfs/zfs-functions
3737
L /etc/zfs/zpool.d - - - - /usr/share/zfs/etc/zfs/zpool.d
38-
C /etc/systemd/system/systemd-udevd.service.d/10-zfs.conf - - - - /usr/lib/systemd/system/systemd-udevd.service.d/10-zfs.conf
38+
r /etc/systemd/system/systemd-udevd.service.d/10-zfs.conf - - - - -
3939
EOF
4040

41-
mkdir -p ./usr/lib/systemd/system/systemd-udevd.service.d
42-
cat <<EOF >./usr/lib/systemd/system/systemd-udevd.service.d/10-zfs.conf
43-
[Unit]
44-
After=systemd-sysext.service
45-
EOF
4641
configure_modprobe flatcar-zfs
4742
popd

‎build_sysext‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,19 @@ for entry in "${BUILD_DIR}/${FLAGS_install_root_basename}"/*; do
289289
rm -rf "${entry}"
290290
done
291291

292+
EXTENSION_RELOAD_MANAGER=0
293+
[[ -d ${BUILD_DIR}/${FLAGS_install_root_basename}/usr/lib/systemd ]] && EXTENSION_RELOAD_MANAGER=1
294+
295+
EXTENSION_RESTART_UNITS=()
296+
[[ -d ${BUILD_DIR}/${FLAGS_install_root_basename}/usr/lib/tmpfiles.d ]] && EXTENSION_RESTART_UNITS+=( systemd-tmpfiles-setup-again.service )
297+
[[ -d ${BUILD_DIR}/${FLAGS_install_root_basename}/usr/lib/udev/rules.d ]] && EXTENSION_RESTART_UNITS+=( systemd-udev-trigger.service )
298+
292299
grep . <<EOF | install -m0644 -D /dev/stdin "${BUILD_DIR}/${FLAGS_install_root_basename}/usr/lib/extension-release.d/extension-release.${SYSEXT_ID}"
293300
ID='flatcar'
294301
${VERSION_FIELD_OVERRIDE:-VERSION_ID}=${FLATCAR_VERSION_ID@Q}
295302
ARCHITECTURE=${ARCH@Q}
296-
EXTENSION_RELOAD_MANAGER=1
303+
EXTENSION_RELOAD_MANAGER=${EXTENSION_RELOAD_MANAGER}
304+
EXTENSION_RESTART_UNITS='${EXTENSION_RESTART_UNITS[*]}'
297305
SYSEXT_ID=${SYSEXT_ID@Q}
298306
${SYSEXT_NAME:+SYSEXT_NAME=${SYSEXT_NAME@Q}}
299307
${PVR:+SYSEXT_VERSION_ID=${PVR@Q}}

‎sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-apps/systemd‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,36 @@ EOF
168168

169169
[Service]
170170
SystemCallFilter=@mount
171+
EOF
172+
)
173+
174+
(
175+
insinto "$(systemd_get_systemunitdir)/systemd-udev-trigger.service.d"
176+
newins - flatcar.conf <<'EOF'
177+
# Ensure udev rules are reloaded before triggering events with them because
178+
# udevd caches its rules for 3 seconds. System extensions that include udev
179+
# rules need them immediately loaded before triggering.
180+
181+
[Service]
182+
ExecStartPre=-udevadm control --reload
183+
EOF
184+
185+
insinto "$(systemd_get_systemunitdir)"
186+
newins - systemd-tmpfiles-setup-again.service <<'EOF'
187+
# System extensions that include tmpfiles.d configuration can restart this
188+
# service to have it processed when merging.
189+
190+
[Unit]
191+
Description=Create System Files and Directories After Booting
192+
Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
193+
194+
[Service]
195+
Type=oneshot
196+
RemainAfterExit=yes
197+
ExecStart=systemd-tmpfiles --create --remove --exclude-prefix=/dev
198+
SuccessExitStatus=DATAERR CANTCREAT
199+
ImportCredential=tmpfiles.*
200+
RestrictSUIDSGID=no
171201
EOF
172202
)
173203
}

0 commit comments

Comments
 (0)