Skip to content

Commit 3d7459c

Browse files
authored
[gbsyncd] Graceful shutdown of syncd process in container gbsyncd (#16812) (#17563)
Fix #16608. Need to gracefully shutdown syncd/gbsyncd individually.
1 parent 9dbb016 commit 3d7459c

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

files/scripts/gbsyncd.sh

+31-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,37 @@ function waitplatform() {
1919
}
2020

2121
function stopplatform1() {
22-
:
22+
if ! docker top gbsyncd$DEV | grep -q /usr/bin/syncd; then
23+
debug "syncd process in container gbsyncd$DEV is not running"
24+
return
25+
fi
26+
27+
# Invoke platform specific pre shutdown routine.
28+
PLATFORM=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' platform`
29+
PLATFORM_PRE_SHUTDOWN="/usr/share/sonic/device/$PLATFORM/plugins/gbsyncd_request_pre_shutdown"
30+
[ -f $PLATFORM_PRE_SHUTDOWN ] && \
31+
/usr/bin/docker exec -i gbsyncd$DEV /usr/share/sonic/platform/plugins/gbsyncd_request_pre_shutdown --${TYPE}
32+
33+
debug "${TYPE} shutdown syncd process in container gbsyncd$DEV ..."
34+
/usr/bin/docker exec -i gbsyncd$DEV /usr/bin/syncd_request_shutdown -g 1 -x /usr/share/sonic/hwsku/context_config.json --${TYPE}
35+
36+
# wait until syncd quits gracefully or force syncd to exit after
37+
# waiting for 20 seconds
38+
start_in_secs=${SECONDS}
39+
end_in_secs=${SECONDS}
40+
timer_threshold=20
41+
while docker top gbsyncd$DEV | grep -q /usr/bin/syncd \
42+
&& [[ $((end_in_secs - start_in_secs)) -le $timer_threshold ]]; do
43+
sleep 0.1
44+
end_in_secs=${SECONDS}
45+
done
46+
47+
if [[ $((end_in_secs - start_in_secs)) -gt $timer_threshold ]]; then
48+
debug "syncd process in container gbsyncd$DEV did not exit gracefully"
49+
fi
50+
51+
/usr/bin/docker exec -i gbsyncd$DEV /bin/sync
52+
debug "Finished ${TYPE} shutdown syncd process in container gbsyncd$DEV ..."
2353
}
2454

2555
function stopplatform2() {

0 commit comments

Comments
 (0)