Skip to content

Commit 128d762

Browse files
authored
[gearbox] Add peer gbsyncd for swss if gearbox exists (#10504)
Fix the issues #10501 and #9733 If having gearbox, we need: * add gbsyncd as a peer since swss also has dependency on gbsyncd * add service gbsyncd to FEATURE table if it is missing
1 parent d853c9c commit 128d762

File tree

3 files changed

+53
-18
lines changed

3 files changed

+53
-18
lines changed

files/scripts/gbsyncd.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
. /usr/local/bin/syncd_common.sh
44

55
function startplatform() {
6-
:
6+
# Add gbsyncd to FEATURE table, if not in. It did have same config as syncd.
7+
if [ -z $($SONIC_DB_CLI CONFIG_DB HGET 'FEATURE|gbsyncd' state) ]; then
8+
local CMD="local r=redis.call('DUMP', KEYS[1]); redis.call('RESTORE', KEYS[2], 0, r)"
9+
$SONIC_DB_CLI CONFIG_DB EVAL "$CMD" 2 'FEATURE|syncd' 'FEATURE|gbsyncd'
10+
fi
711
}
812

913
function waitplatform() {

files/scripts/swss.sh

+40-17
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ start_peer_and_dependent_services() {
112112
check_warm_boot
113113

114114
if [[ x"$WARM_BOOT" != x"true" ]]; then
115-
if [[ ! -z $DEV ]]; then
116-
/bin/systemctl start ${PEER}@$DEV
117-
else
118-
/bin/systemctl start ${PEER}
119-
fi
115+
for peer in ${PEER}; do
116+
if [[ ! -z $DEV ]]; then
117+
/bin/systemctl start ${peer}@$DEV
118+
else
119+
/bin/systemctl start ${peer}
120+
fi
121+
done
120122
for dep in ${DEPENDENT}; do
121123
/bin/systemctl start ${dep}
122124
done
@@ -143,11 +145,13 @@ stop_peer_and_dependent_services() {
143145
for dep in ${DEPENDENT}; do
144146
/bin/systemctl stop ${dep}
145147
done
146-
if [[ ! -z $DEV ]]; then
147-
/bin/systemctl stop ${PEER}@$DEV
148-
else
149-
/bin/systemctl stop ${PEER}
150-
fi
148+
for peer in ${PEER}; do
149+
if [[ ! -z $DEV ]]; then
150+
/bin/systemctl stop ${peer}@$DEV
151+
else
152+
/bin/systemctl stop ${peer}
153+
fi
154+
done
151155
fi
152156
}
153157

@@ -207,11 +211,18 @@ wait() {
207211
# NOTE: This assumes Docker containers share the same names as their
208212
# corresponding services
209213
for SECS in {1..60}; do
210-
if [[ ! -z $DEV ]]; then
211-
RUNNING=$(docker inspect -f '{{.State.Running}}' ${PEER}$DEV)
212-
else
213-
RUNNING=$(docker inspect -f '{{.State.Running}}' ${PEER})
214-
fi
214+
ALL_PEERS_RUNNING=true
215+
for peer in ${PEER}; do
216+
if [[ ! -z $DEV ]]; then
217+
RUNNING=$(docker inspect -f '{{.State.Running}}' ${peer}$DEV)
218+
else
219+
RUNNING=$(docker inspect -f '{{.State.Running}}' ${peer})
220+
fi
221+
if [[ x"$RUNNING" != x"true" ]]; then
222+
ALL_PEERS_RUNNING=false
223+
break
224+
fi
225+
done
215226
ALL_DEPS_RUNNING=true
216227
for dep in ${MULTI_INST_DEPENDENT}; do
217228
if [[ ! -z $DEV ]]; then
@@ -225,7 +236,7 @@ wait() {
225236
fi
226237
done
227238

228-
if [[ x"$RUNNING" == x"true" && x"$ALL_DEPS_RUNNING" == x"true" ]]; then
239+
if [[ x"$ALL_PEERS_RUNNING" == x"true" && x"$ALL_DEPS_RUNNING" == x"true" ]]; then
229240
break
230241
else
231242
sleep 1
@@ -243,7 +254,7 @@ wait() {
243254
done
244255

245256
if [[ ! -z $DEV ]]; then
246-
/usr/bin/docker-wait-any -s ${SERVICE}$DEV -d ${PEER}$DEV ${ALL_DEPS}
257+
/usr/bin/docker-wait-any -s ${SERVICE}$DEV -d `printf "%s$DEV " ${PEER}` ${ALL_DEPS}
247258
else
248259
/usr/bin/docker-wait-any -s ${SERVICE} -d ${PEER} ${ALL_DEPS}
249260
fi
@@ -283,6 +294,17 @@ stop() {
283294
stop_peer_and_dependent_services
284295
}
285296

297+
function check_peer_gbsyncd()
298+
{
299+
PLATFORM=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' platform`
300+
HWSKU=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' hwsku`
301+
GEARBOX_CONFIG=/usr/share/sonic/device/$PLATFORM/$HWSKU/$DEV/gearbox_config.json
302+
303+
if [ -f $GEARBOX_CONFIG ]; then
304+
PEER="$PEER gbsyncd"
305+
fi
306+
}
307+
286308
if [ "$DEV" ]; then
287309
NET_NS="$NAMESPACE_PREFIX$DEV" #name of the network namespace
288310
SONIC_DB_CLI="sonic-db-cli -n $NET_NS"
@@ -291,6 +313,7 @@ else
291313
SONIC_DB_CLI="sonic-db-cli"
292314
fi
293315

316+
check_peer_gbsyncd
294317
read_dependent_services
295318

296319
case "$1" in

platform/components/docker-gbsyncd-credo/supervisord.conf.j2

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ autorestart=unexpected
1010
startretries=0
1111
exitcodes=0,3
1212
events=PROCESS_STATE
13+
buffer_size=1024
14+
15+
[eventlistener:supervisor-proc-exit-listener]
16+
command=/usr/bin/supervisor-proc-exit-listener --container-name gbsyncd
17+
events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING
18+
autostart=true
19+
autorestart=unexpected
20+
buffer_size=1024
1321

1422
[program:rsyslogd]
1523
command=/usr/sbin/rsyslogd -n -iNONE

0 commit comments

Comments
 (0)