Skip to content
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

[teamd]: wait for swss db flush done before starting teamd container #2626

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
#!/bin/bash

DEBUGLOG="/tmp/{{ docker_container_name }}_debug.log"

function debug()
{
/usr/bin/logger $1
/bin/echo `date` "- $1" >> ${DEBUGLOG}
}

function wait_for_swss_db_flush_done()
{
debug "Start waiting for swss"
until [[ $(redis-cli -n 0 GET "SWSS_DB_FLUSH_DONE") ]]; do
debug "Wait 1 second for SWSS_DB_FLUSH_DONE"
sleep 1
done
debug "Swss db flush done"
}

function getMountPoint()
{
echo $1 | python -c "import sys, json, os; mnts = [x for x in json.load(sys.stdin)[0]['Mounts'] if x['Destination'] == '/usr/share/sonic/hwsku']; print '' if len(mnts) == 0 else os.path.basename(mnts[0]['Source'])" 2>/dev/null
Expand Down Expand Up @@ -36,6 +54,8 @@ function preStartAction()
echo -n > /tmp/dump.rdb
docker cp /tmp/dump.rdb database:/var/lib/redis/
fi
{%- elif docker_container_name == "teamd" %}
wait_for_swss_db_flush_done
{%- else %}
: # nothing
{%- endif %}
Expand Down
2 changes: 2 additions & 0 deletions files/scripts/swss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ start() {
/usr/bin/docker exec database redis-cli -n 2 FLUSHDB
/usr/bin/docker exec database redis-cli -n 5 FLUSHDB
clean_up_tables 6 "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*'"
/usr/bin/docker exec database redis-cli -n 0 SET "SWSS_DB_FLUSH_DONE" "1"
fi

# start service docker
Expand Down Expand Up @@ -129,6 +130,7 @@ stop() {

# if warm start enabled or peer lock exists, don't stop peer service docker
if [[ x"$WARM_BOOT" != x"true" ]]; then
/usr/bin/docker exec database redis-cli -n 0 SET "SWSS_DB_FLUSH_DONE" "0"
/bin/systemctl stop ${PEER}
fi
}
Expand Down