-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Separate syncd service from swss service #2051
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2ac7187
[swss.sh] refactor ssh service script code
yxieca 1495afd
[swss.sh] Add debug log for service state changes
yxieca 3550487
[syncd] Separate out syncd service from swss service
yxieca 9540d24
Remove extra 'After' in swss service and remove syncd docker warm boo…
yxieca 45a20d7
[syncd] syncd start/stop/restart shouldn't affect swss state
yxieca 16d061b
add missing '{'
yxieca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| [Unit] | ||
| Description=syncd service | ||
| Requires=database.service updategraph.service | ||
| {% if sonic_asic_platform == 'broadcom' %} | ||
| Requires=opennsl-modules-4.9.0-7-amd64.service | ||
| {% elif sonic_asic_platform == 'nephos' %} | ||
| Requires=nps-modules-4.9.0-7-amd64.service | ||
| {% endif %} | ||
| After=database.service updategraph.service | ||
| After=interfaces-config.service | ||
| {% if sonic_asic_platform == 'broadcom' %} | ||
| After=opennsl-modules-4.9.0-7-amd64.service | ||
| {% elif sonic_asic_platform == 'nephos' %} | ||
| After=nps-modules-4.9.0-7-amd64.service | ||
yxieca marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {% endif %} | ||
|
|
||
| [Service] | ||
| User=root | ||
| Environment=sonic_asic_platform={{ sonic_asic_platform }} | ||
| ExecStart=/usr/local/bin/syncd.sh start | ||
| ExecStop=/usr/local/bin/syncd.sh stop | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| #!/bin/bash | ||
|
|
||
| SERVICE="syncd" | ||
| PEER="swss" | ||
| DEBUGLOG="/tmp/swss-syncd-debug.log" | ||
| LOCKFILE="/tmp/swss-syncd-lock" | ||
|
|
||
| function debug() | ||
| { | ||
| /bin/echo `date` "- $1" >> ${DEBUGLOG} | ||
| } | ||
|
|
||
| function lock_service_state_change() | ||
| { | ||
| debug "Locking ${LOCKFILE} from ${SERVICE} service" | ||
|
|
||
| exec {LOCKFD}>${LOCKFILE} | ||
| /usr/bin/flock -x ${LOCKFD} | ||
| trap "/usr/bin/flock -u ${LOCKFD}" 0 2 3 15 | ||
|
|
||
| debug "Locked ${LOCKFILE} (${LOCKFD}) from ${SERVICE} service" | ||
| } | ||
|
|
||
| function unlock_service_state_change() | ||
| { | ||
| debug "Unlocking ${LOCKFILE} (${LOCKFD}) from ${SERVICE} service" | ||
| /usr/bin/flock -u ${LOCKFD} | ||
| } | ||
|
|
||
| function check_warm_boot() | ||
| { | ||
| SYSTEM_WARM_START=`/usr/bin/redis-cli -n 4 hget "WARM_RESTART|system" enable` | ||
| # SYSTEM_WARM_START could be empty, always make WARM_BOOT meaningful. | ||
| if [[ x"$SYSTEM_WARM_START" == x"true" ]]; then | ||
| WARM_BOOT="true" | ||
| else | ||
| WARM_BOOT="false" | ||
| fi | ||
| } | ||
|
|
||
| function wait_for_database_service() | ||
| { | ||
| # Wait for redis server start before database clean | ||
| until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]]; | ||
| do sleep 1; | ||
| done | ||
|
|
||
| # Wait for configDB initialization | ||
| until [[ $(/usr/bin/docker exec database redis-cli -n 4 GET "CONFIG_DB_INITIALIZED") ]]; | ||
| do sleep 1; | ||
| done | ||
| } | ||
|
|
||
| start() { | ||
| debug "Starting ${SERVICE} service..." | ||
|
|
||
| lock_service_state_change | ||
|
|
||
| wait_for_database_service | ||
| check_warm_boot | ||
|
|
||
| debug "Warm boot flag: ${SERVICE} ${WARM_BOOT}." | ||
|
|
||
| # Don't flush DB during warm boot | ||
| if [[ x"$WARM_BOOT" != x"true" ]]; then | ||
| /usr/bin/docker exec database redis-cli -n 1 FLUSHDB | ||
|
|
||
| # platform specific tasks | ||
| if [ x$sonic_asic_platform == x'mellanox' ]; then | ||
| FAST_BOOT=1 | ||
| /usr/bin/mst start | ||
| /usr/bin/mlnx-fw-upgrade.sh | ||
| /etc/init.d/sxdkernel start | ||
| /sbin/modprobe i2c-dev | ||
| /etc/mlnx/mlnx-hw-management start | ||
| elif [ x$sonic_asic_platform == x'cavium' ]; then | ||
| /etc/init.d/xpnet.sh start | ||
| fi | ||
| fi | ||
|
|
||
| # start service docker | ||
| /usr/bin/${SERVICE}.sh start | ||
| debug "Started ${SERVICE} service..." | ||
|
|
||
| unlock_service_state_change | ||
| /usr/bin/${SERVICE}.sh attach | ||
| } | ||
|
|
||
| stop() { | ||
| debug "Stopping ${SERVICE} service..." | ||
|
|
||
| lock_service_state_change | ||
| check_warm_boot | ||
| debug "Warm boot flag: ${SERVICE} ${WARM_BOOT}." | ||
|
|
||
| /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/mlnx/mlnx-hw-management stop | ||
| /etc/init.d/sxdkernel stop | ||
| /usr/bin/mst stop | ||
| elif [ x$sonic_asic_platform == x'cavium' ]; then | ||
| /etc/init.d/xpnet.sh stop | ||
| /etc/init.d/xpnet.sh start | ||
| fi | ||
| fi | ||
|
|
||
| unlock_service_state_change | ||
| } | ||
|
|
||
| case "$1" in | ||
| start|stop) | ||
| $1 | ||
| ;; | ||
| *) | ||
| echo "Usage: $0 {start|stop}" | ||
| exit 1 | ||
| ;; | ||
| esac |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.