Skip to content

Commit 143814c

Browse files
Junchao-Mellanoxmssonicbld
authored andcommitted
Fix issue: systemctl daemon-reload would sporadically cause udev handler fail (#15253)
#### Why I did it A workaround to back port the fix for a systemd issue. The systemd issue: systemd/systemd#24668 The systemd PR to fix the issue: https://github.com/systemd/systemd/pull/24673/files The formal solution should upgrade systemd to a version that contains the fix. But, systemd is a very basic service, upgrading systemd requires heavy test. #### How I did it Copy the correct systemd-udevd.service file in build time #### Tested branch (Please provide the tested image version) - [x] 202211 - [ ] <!-- image version 2 --> ``` SONiC Software Version: SONiC.fix-udev.3-b65c7bdec_Internal SONiC OS Version: 11 Distribution: Debian 11.7 Kernel: 5.10.0-18-2-amd64 Build commit: b65c7bd Build date: Mon Jun 19 10:54:50 UTC 2023 Built by: sw-r2d2-bot@r-build-sonic-ci02-241 Platform: x86_64-mlnx_msn4700-r0 HwSKU: ACS-MSN4700 ASIC: mellanox ASIC Count: 1 Serial Number: MT2022X08597 Model Number: MSN4700-WS2FO Hardware Revision: A1 Uptime: 08:10:11 up 1 min, 1 user, load average: 1.81, 0.67, 0.24 Date: Sun 25 Jun 2023 08:10:11 Docker images: REPOSITORY TAG IMAGE ID SIZE docker-fpm-frr fix-udev.3-b65c7bdec_Internal a7b911e7cb6f 346MB docker-fpm-frr latest a7b911e7cb6f 346MB docker-platform-monitor fix-udev.3-b65c7bdec_Internal 94c5178cf80b 731MB docker-platform-monitor latest 94c5178cf80b 731MB docker-orchagent fix-udev.3-b65c7bdec_Internal 46b393e0ace8 328MB docker-orchagent latest 46b393e0ace8 328MB docker-syncd-mlnx fix-udev.3-b65c7bdec_Internal 1f5c6c23e33a 734MB docker-syncd-mlnx latest 1f5c6c23e33a 734MB docker-sflow fix-udev.3-b65c7bdec_Internal 7e45992c8c59 317MB docker-sflow latest 7e45992c8c59 317MB docker-teamd fix-udev.3-b65c7bdec_Internal e4d905592cda 316MB docker-teamd latest e4d905592cda 316MB docker-nat fix-udev.3-b65c7bdec_Internal 7fe799367580 319MB docker-nat latest 7fe799367580 319MB docker-macsec latest d702a5554171 318MB docker-snmp fix-udev.3-b65c7bdec_Internal 3bce8fcf71cd 338MB docker-snmp latest 3bce8fcf71cd 338MB docker-sonic-telemetry fix-udev.3-b65c7bdec_Internal f13949cbc817 597MB docker-sonic-telemetry latest f13949cbc817 597MB docker-dhcp-relay latest 153d9072805d 306MB docker-router-advertiser fix-udev.3-b65c7bdec_Internal aed642b9a6bc 299MB docker-router-advertiser latest aed642b9a6bc 299MB docker-sonic-p4rt fix-udev.3-b65c7bdec_Internal a3cae5ca65a7 870MB docker-sonic-p4rt latest a3cae5ca65a7 870MB docker-mux fix-udev.3-b65c7bdec_Internal b81f0401b9a8 347MB docker-mux latest b81f0401b9a8 347MB docker-eventd fix-udev.3-b65c7bdec_Internal c5917d0e801f 298MB docker-eventd latest c5917d0e801f 298MB docker-lldp fix-udev.3-b65c7bdec_Internal fd5dc14a7976 341MB docker-lldp latest fd5dc14a7976 341MB docker-database fix-udev.3-b65c7bdec_Internal 438c2715a1dd 299MB docker-database latest 438c2715a1dd 299MB docker-sonic-mgmt-framework fix-udev.3-b65c7bdec_Internal 5c50b115fbcd 414MB docker-sonic-mgmt-framework latest ```
1 parent 923da6f commit 143814c

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

build_debian.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ sudo LANG=C chroot $FILESYSTEM_ROOT mount
108108
[ -d $TRUSTED_GPG_DIR ] && [ ! -z "$(ls $TRUSTED_GPG_DIR)" ] && sudo cp $TRUSTED_GPG_DIR/* ${FILESYSTEM_ROOT}/etc/apt/trusted.gpg.d/
109109

110110
## Pointing apt to public apt mirrors and getting latest packages, needed for latest security updates
111-
scripts/build_mirror_config.sh files/apt $CONFIGURED_ARCH $IMAGE_DISTRO
111+
scripts/build_mirror_config.sh files/apt $CONFIGURED_ARCH $IMAGE_DISTRO
112112
sudo cp files/apt/sources.list.$CONFIGURED_ARCH $FILESYSTEM_ROOT/etc/apt/sources.list
113113
sudo cp files/apt/apt.conf.d/{81norecommends,apt-{clean,gzip-indexes,no-languages},no-check-valid-until,apt-multiple-retries} $FILESYSTEM_ROOT/etc/apt/apt.conf.d/
114114

@@ -283,7 +283,7 @@ then
283283
## Install Kubernetes master
284284
echo '[INFO] Install kubernetes master'
285285
install_kubernetes ${MASTER_KUBERNETES_VERSION}
286-
286+
287287
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT curl -fsSL \
288288
https://packages.microsoft.com/keys/microsoft.asc | \
289289
sudo LANG=C chroot $FILESYSTEM_ROOT apt-key add -
@@ -298,7 +298,7 @@ then
298298
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y remove gnupg
299299
sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT curl -o /tmp/cri-dockerd.deb -fsSL \
300300
https://github.com/Mirantis/cri-dockerd/releases/download/v${MASTER_CRI_DOCKERD}/cri-dockerd_${MASTER_CRI_DOCKERD}.3-0.debian-${IMAGE_DISTRO}_amd64.deb
301-
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install -f /tmp/cri-dockerd.deb
301+
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install -f /tmp/cri-dockerd.deb
302302
sudo LANG=C chroot $FILESYSTEM_ROOT rm -f /tmp/cri-dockerd.deb
303303
else
304304
echo '[INFO] Skipping Install kubernetes master'
@@ -436,6 +436,14 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in
436436
systemd-sysv \
437437
ntp
438438

439+
# Workaround for issue: The udev rule may fail to be executed because the
440+
# daemon-reload command is executed in parallel
441+
# Github issue: https://github.com/systemd/systemd/issues/24668
442+
# Github PR: https://github.com/systemd/systemd/pull/24673
443+
# This workaround should be removed after a upstream already contains the fixes
444+
sudo patch $FILESYSTEM_ROOT/lib/systemd/system/systemd-udevd.service \
445+
files/image_config/systemd/systemd-udevd/fix-udev-rule-may-fail-if-daemon-reload-command-runs.patch
446+
439447
if [[ $TARGET_BOOTLOADER == grub ]]; then
440448
if [[ $CONFIGURED_ARCH == amd64 ]]; then
441449
GRUB_PKG=grub-pc-bin
@@ -623,10 +631,10 @@ then
623631
fi
624632

625633
# #################
626-
# secure boot
634+
# secure boot
627635
# #################
628636
if [[ $SECURE_UPGRADE_MODE == 'dev' || $SECURE_UPGRADE_MODE == "prod" && $SONIC_ENABLE_SECUREBOOT_SIGNATURE != 'y' ]]; then
629-
# note: SONIC_ENABLE_SECUREBOOT_SIGNATURE is a feature that signing just kernel,
637+
# note: SONIC_ENABLE_SECUREBOOT_SIGNATURE is a feature that signing just kernel,
630638
# SECURE_UPGRADE_MODE is signing all the boot component including kernel.
631639
# its required to do not enable both features together to avoid conflicts.
632640
echo "Secure Boot support build stage: Starting .."
@@ -635,14 +643,14 @@ if [[ $SECURE_UPGRADE_MODE == 'dev' || $SECURE_UPGRADE_MODE == "prod" && $SONIC_
635643
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install \
636644
shim-unsigned \
637645
grub-efi
638-
646+
639647
if [ ! -f $SECURE_UPGRADE_SIGNING_CERT ]; then
640648
echo "Error: SONiC SECURE_UPGRADE_SIGNING_CERT=$SECURE_UPGRADE_SIGNING_CERT key missing"
641649
exit 1
642650
fi
643651

644652
if [[ $SECURE_UPGRADE_MODE == 'dev' ]]; then
645-
# development signing & verification
653+
# development signing & verification
646654

647655
if [ ! -f $SECURE_UPGRADE_DEV_SIGNING_KEY ]; then
648656
echo "Error: SONiC SECURE_UPGRADE_DEV_SIGNING_KEY=$SECURE_UPGRADE_DEV_SIGNING_KEY key missing"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -------------------------------------------------------------------
2+
# Patch for /lib/systemd/system/systemd-udevd.service
3+
# Fix issue: The udev rule may fail to be executed because the
4+
# daemon-reload command is executed in parallel
5+
# Github issue: https://github.com/systemd/systemd/issues/24668
6+
# Github PR: https://github.com/systemd/systemd/pull/24673
7+
# -------------------------------------------------------------------
8+
@@ -16,8 +16,6 @@
9+
ConditionPathIsReadWrite=/sys
10+
11+
[Service]
12+
-DeviceAllow=block-* rwm
13+
-DeviceAllow=char-* rwm
14+
Type=notify
15+
# Note that udev will reset the value internally for its workers
16+
OOMScoreAdjust=-1000
17+
@@ -29,7 +27,6 @@
18+
KillMode=mixed
19+
TasksMax=infinity
20+
PrivateMounts=yes
21+
-ProtectClock=yes
22+
ProtectHostname=yes
23+
MemoryDenyWriteExecute=yes
24+
RestrictAddressFamilies=AF_UNIX AF_NETLINK AF_INET AF_INET6

0 commit comments

Comments
 (0)