From 142375eb7de0e2e7da744e62884a3db6af35ed8f Mon Sep 17 00:00:00 2001 From: marif-nexthop Date: Wed, 14 Jan 2026 22:25:42 -0800 Subject: [PATCH] [Nexthop] Upgrade FBOSS Distro to support systemd services and add service for FBOSS platform_manager **Pre-submission checklist** - [x] I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running `pip install -r requirements-dev.txt && pre-commit install` - [x] `pre-commit run` Upgraded FBOSS Distro to support systemd services and add `systemd` service integration for `platform_manager` to enable automatic startup on boot. - Add `services/platform_manager.service` systemd unit file - Update `build_image_in_container.sh` to copy service files from `services/` directory to the root overlay - Update `config.sh` to enable `platform_manager.service` during image build - Built PXE and ONIE images successfully - Verified service installs and enables correctly - Confirmed journald logging works ``` [root@gold222 ~]# systemctl status platform_manager.service platform_manager.service - FBOSS Platform Manager Loaded: loaded (/usr/lib/systemd/system/platform_manager.service; enabled; preset: disabled) ``` ``` [root@gold222 fboss]# journalctl -u platform_manager ... Jan 09 07:53:25 gold222 systemd[1]: platform_manager.service: Scheduled restart job, restart counter is at 5. Jan 09 07:53:25 gold222 systemd[1]: Stopped FBOSS Platform Manager. Jan 09 07:53:25 gold222 systemd[1]: Started FBOSS Platform Manager. Jan 09 07:53:25 gold222 platform_manager[1112]: I0109 07:53:25.284380 1112 PlatformNameLib.cpp:56] Getting platform na me from bios using dmidecode ... Jan 09 07:53:25 gold222 platform_manager[1112]: I0109 07:53:25.286804 1112 PlatformNameLib.cpp:65] Platform name infer red from bios: NH-4010 Jan 09 07:53:25 gold222 platform_manager[1112]: I0109 07:53:25.286823 1112 PlatformNameLib.cpp:67] Platform name mappe d: NH-4010 ``` --- .../bin/build_image_in_container.sh | 8 +++++ .../templates/centos-09.0/config.sh | 4 +++ .../services/platform_manager.service | 32 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 fboss-image/image_builder/templates/centos-09.0/services/platform_manager.service diff --git a/fboss-image/image_builder/bin/build_image_in_container.sh b/fboss-image/image_builder/bin/build_image_in_container.sh index 31e46f8156f5c..13b0bbc249ec4 100755 --- a/fboss-image/image_builder/bin/build_image_in_container.sh +++ b/fboss-image/image_builder/bin/build_image_in_container.sh @@ -156,6 +156,14 @@ cp /etc/resolv.conf "${DESCRIPTION_DIR}/root/etc/" # Add build timestamp to the image echo "Built on: $(date -u)" >"$DESCRIPTION_DIR/root/etc/build-info" +# Copy systemd service files to overlay +if [ -d "${DESCRIPTION_DIR}/services" ]; then + dprint "Copying systemd service files to overlay..." + rm -rf ${DESCRIPTION_DIR}/root/usr/lib/systemd/system + mkdir -p ${DESCRIPTION_DIR}/root/usr/lib/systemd/system + cp ${DESCRIPTION_DIR}/services/*.service ${DESCRIPTION_DIR}/root/usr/lib/systemd/system/ +fi + # Generate the images dprint "Generating PXE and USB bootable image, this will take few minutes..." kiwi-ng-3 \ diff --git a/fboss-image/image_builder/templates/centos-09.0/config.sh b/fboss-image/image_builder/templates/centos-09.0/config.sh index dd86f33d0495e..3baec3893699a 100755 --- a/fboss-image/image_builder/templates/centos-09.0/config.sh +++ b/fboss-image/image_builder/templates/centos-09.0/config.sh @@ -51,6 +51,10 @@ env -i \ PATH="/usr/bin:/usr/sbin:/bin:/sbin" \ kernel-install add "${KERNEL_VERSION}" "${VMLINUZ_PATH}" --initrd-file "${INITRD_PATH}" +# 5. Enable systemd services +echo "Enabling FBOSS systemd services..." +systemctl enable platform_manager.service + # 6. Done! Cleanup, remember that we are chrooted on the rootfs echo "Removing kernel rpms from rootfs..." rm -f /repos/*.rpm diff --git a/fboss-image/image_builder/templates/centos-09.0/services/platform_manager.service b/fboss-image/image_builder/templates/centos-09.0/services/platform_manager.service new file mode 100644 index 0000000000000..531acd62eb61e --- /dev/null +++ b/fboss-image/image_builder/templates/centos-09.0/services/platform_manager.service @@ -0,0 +1,32 @@ +# /usr/lib/systemd/system/platform_manager.service +[Unit] +Description=FBOSS Platform Manager +Before=sensor_service.service +Before=fan_service.service +Before=data_corral_service.service +Before=led_service.service +Before=qsfp_service.service +Before=fruid.service +After=rc-local.service + +[Service] +Type=notify +LimitNOFILE=10000000 +LimitCORE=32G + +Environment="PATH=/opt/fboss/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" +Environment="LD_LIBRARY_PATH=/opt/fboss/lib" +WorkingDirectory=/opt/fboss +ExecStart=/bin/bash -c 'source /opt/fboss/bin/setup_fboss_env && exec /opt/fboss/bin/platform_manager --run_once=false' + +Restart=on-failure +RestartSec=30 +TimeoutStartSec=180s + +# Logging to journald +StandardOutput=journal +StandardError=journal +SyslogIdentifier=platform_manager + +[Install] +WantedBy=multi-user.target