Skip to content
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

[syncd]: Fix reload flow for Mellanox platforms #2386

Merged
merged 1 commit into from
Dec 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 48 additions & 19 deletions files/scripts/syncd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ function wait_for_database_service()
done
}

function getBootType()
{
case "$(cat /proc/cmdline | grep -o 'SONIC_BOOT_TYPE=\S*' | cut -d'=' -f2)" in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SONIC_BOOT_TYPE= [](start = 41, length = 16)

We should handle both cases for backward-compatible with 201803:

fast-reboot
SONIC_BOOT_TYPE=fast-reboot
Otherwise we cannot fast-reboot from 201803 into 201811.

warm*)
TYPE='warm'
;;
fastfast)
TYPE='fastfast'
;;
fast*)
TYPE='fast'
;;
*)
TYPE='cold'
esac
echo "${TYPE}"
}

start() {
debug "Starting ${SERVICE} service..."

Expand All @@ -74,17 +92,23 @@ start() {
/usr/bin/docker exec database redis-cli -n 1 FLUSHDB

# platform specific tasks
if [ x$sonic_asic_platform == x'mellanox' ]; then
export FAST_BOOT=1
/usr/bin/mst start
/usr/bin/mlnx-fw-upgrade.sh
/etc/init.d/sxdkernel start
/sbin/modprobe i2c-dev
elif [ x$sonic_asic_platform == x'cavium' ]; then
if [ x$sonic_asic_platform == x'cavium' ]; then
/etc/init.d/xpnet.sh start
fi
fi

# platform specific tasks
if [ x"$sonic_asic_platform" == x"mellanox" ]; then
BOOT_TYPE=`getBootType`
if [[ x"$WARM_BOOT" == x"true" || x"$BOOT_TYPE" == x"fast" ]]; then
export FAST_BOOT=1
fi
/usr/bin/mst start
/usr/bin/mlnx-fw-upgrade.sh
/etc/init.d/sxdkernel start
/sbin/modprobe i2c-dev
fi

# start service docker
/usr/bin/${SERVICE}.sh start
debug "Started ${SERVICE} service..."
Expand All @@ -106,32 +130,37 @@ stop() {
TYPE=cold
fi

debug "${TYPE} shutdown syncd process ..."
/usr/bin/docker exec -i syncd /usr/bin/syncd_request_shutdown --${TYPE}
if [[ x$sonic_asic_platform != x"mellanox" ]] || [[ x$TYPE != x"cold" ]]; then
debug "${TYPE} shutdown syncd process ..."
/usr/bin/docker exec -i syncd /usr/bin/syncd_request_shutdown --${TYPE}

# wait until syncd quits gracefully
while docker top syncd | grep -q /usr/bin/syncd; do
sleep 0.1
done
# wait until syncd quits gracefully
while docker top syncd | grep -q /usr/bin/syncd; do
sleep 0.1
done

/usr/bin/docker exec -i syncd /bin/sync
debug "Finished ${TYPE} shutdown syncd process ..."
/usr/bin/docker exec -i syncd /bin/sync
debug "Finished ${TYPE} shutdown syncd process ..."
fi

/usr/bin/${SERVICE}.sh stop
debug "Stopped ${SERVICE} service..."

# if warm start enabled, don't stop peer service docker
if [[ x"$WARM_BOOT" != x"true" ]]; then
# platform specific tasks
if [ x$sonic_asic_platform == x'mellanox' ]; then
/etc/init.d/sxdkernel stop
/usr/bin/mst stop
elif [ x$sonic_asic_platform == x'cavium' ]; then
if [ x$sonic_asic_platform == x'cavium' ]; then
/etc/init.d/xpnet.sh stop
/etc/init.d/xpnet.sh start
fi
fi

# platform specific tasks
if [ x"$sonic_asic_platform" == x"mellanox" ]; then
/etc/init.d/sxdkernel stop
/usr/bin/mst stop
fi

unlock_service_state_change
}

Expand Down