Skip to content

Commit a41d9a5

Browse files
committed
[service dependent] describe non-warm-reboot dependency outside systemd (sonic-net#3311)
* [service dependent] describe non-warm-reboot dependency outside systemctl When dependency was described with systemctl, it will kick in all the time, including under warm reboot/restart scenarios. This is not what we always want. For components that are capable of warm reboot/start, they need to describe dependency in service files. Signed-off-by: Ying Xie <ying.xie@microsoft.com> * [service] teamd service should not require swss service Adding require swss will cause teamd to be killed by systemctl when swss stops. This is not what we want in warm reboot. Signed-off-by: Ying Xie <ying.xie@microsoft.com> * refactoring code * rename functions to match other functions in the file
1 parent c29e2e2 commit a41d9a5

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

files/build_templates/teamd.service.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[Unit]
22
Description=TEAMD container
3-
Requires=updategraph.service swss.service
3+
Requires=updategraph.service
44
After=updategraph.service swss.service
55
Before=ntp-config.service
66

@@ -11,4 +11,4 @@ ExecStart=/usr/bin/{{docker_container_name}}.sh wait
1111
ExecStop=/usr/bin/{{docker_container_name}}.sh stop
1212

1313
[Install]
14-
WantedBy=multi-user.target swss.service
14+
WantedBy=multi-user.target

files/scripts/swss.sh

+17-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
SERVICE="swss"
44
PEER="syncd"
5+
DEPENDENT="teamd"
56
DEBUGLOG="/tmp/swss-syncd-debug.log"
67
LOCKFILE="/tmp/swss-syncd-lock"
78

@@ -78,11 +79,24 @@ function clean_up_tables()
7879
end" 0
7980
}
8081

81-
startPeerService() {
82+
start_peer_and_dependent_services() {
8283
check_warm_boot
8384

8485
if [[ x"$WARM_BOOT" != x"true" ]]; then
8586
/bin/systemctl start ${PEER}
87+
for dep in ${DEPENDENT}; do
88+
/bin/systemctl start ${dep}
89+
done
90+
fi
91+
}
92+
93+
stop_peer_and_dependent_services() {
94+
# if warm start enabled or peer lock exists, don't stop peer service docker
95+
if [[ x"$WARM_BOOT" != x"true" ]]; then
96+
/bin/systemctl stop ${PEER}
97+
for dep in ${DEPENDENT}; do
98+
/bin/systemctl stop ${dep}
99+
done
86100
fi
87101
}
88102

@@ -116,7 +130,7 @@ start() {
116130
}
117131

118132
wait() {
119-
startPeerService
133+
start_peer_and_dependent_services
120134
/usr/bin/${SERVICE}.sh wait
121135
}
122136

@@ -135,10 +149,7 @@ stop() {
135149
# Unlock has to happen before reaching out to peer service
136150
unlock_service_state_change
137151

138-
# if warm start enabled or peer lock exists, don't stop peer service docker
139-
if [[ x"$WARM_BOOT" != x"true" ]]; then
140-
/bin/systemctl stop ${PEER}
141-
fi
152+
stop_peer_and_dependent_services
142153
}
143154

144155
case "$1" in

0 commit comments

Comments
 (0)