Skip to content

Commit

Permalink
[swss]: Update swss.sh script to clean up specific db when start
Browse files Browse the repository at this point in the history
This script shall not flush all the entries in the state database
when it starts up, since there are entries maintained and written
by other processes outside this docker.

The issue we noticed was that the portchannel states are cleaned
up after teamsyncd writes the entries into the database, which
causes the IPs failed to be configured because intfmgrd considers
the portchannels are not ready yet.

Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
  • Loading branch information
Shu0T1an ChenG committed Nov 2, 2018
1 parent 8b67424 commit b1f8e7a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion files/scripts/swss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ function wait_for_database_service()
done
}

# This function cleans up the tables with specific prefixes from the database
# $1 the index of the database
# $2 the string of a list of table prefixes
function clean_up_tables()
{
redis-cli -n $1 EVAL "
local tables = {$2}
for i = 1, table.getn(tables) do
local matches = redis.call('KEYS', tables[i])
for j,name in ipairs(matches) do
redis.call('DEL', name)
end
end" 0
}

start() {
debug "Starting ${SERVICE} service..."

Expand All @@ -78,7 +93,7 @@ start() {
/usr/bin/docker exec database redis-cli -n 0 FLUSHDB
/usr/bin/docker exec database redis-cli -n 2 FLUSHDB
/usr/bin/docker exec database redis-cli -n 5 FLUSHDB
/usr/bin/docker exec database redis-cli -n 6 FLUSHDB
clean_up_tables 6 "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'WARM_RESTART_TABLE*'"
fi

# start service docker
Expand Down

0 comments on commit b1f8e7a

Please sign in to comment.