From 0e84418e91905cfc01a9f5e76f1083a44eff5ec7 Mon Sep 17 00:00:00 2001 From: Aravind Mani <53524901+aravindmani-1@users.noreply.github.com> Date: Thu, 15 Apr 2021 09:37:59 -0700 Subject: [PATCH] Stop PMON docker before cold and soft reboots (#1514) Prevent potential kernel oops if drivers are removed/devices are deinitialized while PMon daemons are still trying to access those devices. --- scripts/reboot | 13 +++++++++++++ scripts/soft-reboot | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/scripts/reboot b/scripts/reboot index 24607fb09590..546aa0fbff8b 100755 --- a/scripts/reboot +++ b/scripts/reboot @@ -50,17 +50,30 @@ function tag_images() fi } +function stop_pmon_service() +{ + CONTAINER_STOP_RC=0 + debug "Stopping pmon docker" + docker kill pmon &> /dev/null || CONTAINER_STOP_RC=$? + systemctl stop pmon || debug "Ignore stopping pmon error $?" + if [[ CONTAINER_STOP_RC -ne 0 ]]; then + debug "Failed killing container pmon RC $CONTAINER_STOP_RC ." + fi +} + function stop_sonic_services() { if [[ x"$SUBTYPE" == x"DualToR" ]]; then debug "DualToR detected, stopping mux container before reboot..." systemctl stop mux fi + if [[ x"$ASIC_TYPE" != x"mellanox" ]]; then debug "Stopping syncd process..." docker exec -i syncd /usr/bin/syncd_request_shutdown --cold > /dev/null sleep 3 fi + stop_pmon_service } function clear_warm_boot() diff --git a/scripts/soft-reboot b/scripts/soft-reboot index 52ccdd690b0d..504c58caffee 100755 --- a/scripts/soft-reboot +++ b/scripts/soft-reboot @@ -59,6 +59,17 @@ function tag_images() fi } +function stop_pmon_service() +{ + CONTAINER_STOP_RC=0 + debug "Stopping pmon docker" + docker kill pmon &> /dev/null || CONTAINER_STOP_RC=$? + systemctl stop pmon || debug "Ignore stopping pmon error $?" + if [[ CONTAINER_STOP_RC -ne 0 ]]; then + debug "Failed killing container pmon RC $CONTAINER_STOP_RC ." + fi +} + function stop_sonic_services() { if [[ x"$ASIC_TYPE" != x"mellanox" ]]; then @@ -66,6 +77,7 @@ function stop_sonic_services() docker exec -i syncd /usr/bin/syncd_request_shutdown --cold > /dev/null sleep 3 fi + stop_pmon_service } function clear_lingering_reboot_config()