Skip to content

Commit

Permalink
[service dependent] describe non-warm-reboot dependency outside syste…
Browse files Browse the repository at this point in the history
…md (#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
  • Loading branch information
yxieca committed Aug 8, 2019
1 parent c29e2e2 commit a41d9a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions files/build_templates/teamd.service.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Unit]
Description=TEAMD container
Requires=updategraph.service swss.service
Requires=updategraph.service
After=updategraph.service swss.service
Before=ntp-config.service

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

[Install]
WantedBy=multi-user.target swss.service
WantedBy=multi-user.target
23 changes: 17 additions & 6 deletions files/scripts/swss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

SERVICE="swss"
PEER="syncd"
DEPENDENT="teamd"
DEBUGLOG="/tmp/swss-syncd-debug.log"
LOCKFILE="/tmp/swss-syncd-lock"

Expand Down Expand Up @@ -78,11 +79,24 @@ function clean_up_tables()
end" 0
}

startPeerService() {
start_peer_and_dependent_services() {
check_warm_boot

if [[ x"$WARM_BOOT" != x"true" ]]; then
/bin/systemctl start ${PEER}
for dep in ${DEPENDENT}; do
/bin/systemctl start ${dep}
done
fi
}

stop_peer_and_dependent_services() {
# if warm start enabled or peer lock exists, don't stop peer service docker
if [[ x"$WARM_BOOT" != x"true" ]]; then
/bin/systemctl stop ${PEER}
for dep in ${DEPENDENT}; do
/bin/systemctl stop ${dep}
done
fi
}

Expand Down Expand Up @@ -116,7 +130,7 @@ start() {
}

wait() {
startPeerService
start_peer_and_dependent_services
/usr/bin/${SERVICE}.sh wait
}

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

# if warm start enabled or peer lock exists, don't stop peer service docker
if [[ x"$WARM_BOOT" != x"true" ]]; then
/bin/systemctl stop ${PEER}
fi
stop_peer_and_dependent_services
}

case "$1" in
Expand Down

0 comments on commit a41d9a5

Please sign in to comment.