Skip to content

[202012] [Fastboot] Delay PMON service for better fastboot performance #10745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 16, 2022
4 changes: 2 additions & 2 deletions files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
{%- set features = [("bgp", "enabled", false, "enabled"),
("database", "always_enabled", false, "always_enabled"),
("dhcp_relay", "enabled", false, "enabled"),
("lldp", "enabled", false, "enabled"),
("pmon", "enabled", false, "enabled"),
("lldp", "enabled", true, "enabled"),
("pmon", "enabled", true, "enabled"),
("radv", "enabled", false, "enabled"),
("snmp", "enabled", true, "enabled"),
("swss", "enabled", false, "enabled"),
Expand Down
3 changes: 0 additions & 3 deletions files/build_templates/pmon.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ ExecStart=/usr/bin/{{docker_container_name}}.sh wait
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
Restart=always
RestartSec=30

[Install]
WantedBy=sonic.target
12 changes: 12 additions & 0 deletions files/build_templates/pmon.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
# This delay is for fast/warm reboot performance
Description=Delays pmon docker until SONiC has started
PartOf=pmon.service

[Timer]
OnUnitActiveSec=0 sec
OnBootSec=1min 30 sec
Unit=pmon.service

[Install]
WantedBy=timers.target sonic.target sonic-delayed.target
3 changes: 3 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@ sudo cp $BUILD_TEMPLATES/mgmt-framework.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_S
echo "mgmt-framework.timer" | sudo tee -a $GENERATED_SERVICE_FILE
{% endif %}

sudo cp $BUILD_TEMPLATES/pmon.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
echo "pmon.timer" | sudo tee -a $GENERATED_SERVICE_FILE

sudo cp $BUILD_TEMPLATES/sonic.target $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable sonic.target

Expand Down
17 changes: 11 additions & 6 deletions files/scripts/syncd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,16 @@ function startplatform() {
}

function waitplatform() {


BOOT_TYPE=`getBootType`
if [[ x"$sonic_asic_platform" == x"mellanox" ]]; then
debug "Starting pmon service..."
/bin/systemctl start pmon
debug "Started pmon service"
if [[ x"$BOOT_TYPE" = @(x"fast"|x"warm"|x"fastfast") ]]; then
debug "PMON service is delayed by a timer for better fast/warm boot performance"
else
debug "Starting pmon service..."
/bin/systemctl start pmon
debug "Started pmon service"
fi
fi
}

Expand All @@ -56,7 +61,7 @@ function stopplatform1() {
debug "${TYPE} shutdown syncd process ..."
/usr/bin/docker exec -i syncd$DEV /usr/bin/syncd_request_shutdown --${TYPE}

# wait until syncd quits gracefully or force syncd to exit after
# wait until syncd quits gracefully or force syncd to exit after
# waiting for 20 seconds
start_in_secs=${SECONDS}
end_in_secs=${SECONDS}
Expand All @@ -68,7 +73,7 @@ function stopplatform1() {
done

if [[ $((end_in_secs - start_in_secs)) -gt $timer_threshold ]]; then
debug "syncd process in container syncd$DEV did not exit gracefully"
debug "syncd process in container syncd$DEV did not exit gracefully"
fi

/usr/bin/docker exec -i syncd$DEV /bin/sync
Expand Down