Skip to content

Commit b1f8e7a

Browse files
author
Shu0T1an ChenG
committed
[swss]: Update swss.sh script to clean up specific db when start
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 <[email protected]>
1 parent 8b67424 commit b1f8e7a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

files/scripts/swss.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ function wait_for_database_service()
6262
done
6363
}
6464

65+
# This function cleans up the tables with specific prefixes from the database
66+
# $1 the index of the database
67+
# $2 the string of a list of table prefixes
68+
function clean_up_tables()
69+
{
70+
redis-cli -n $1 EVAL "
71+
local tables = {$2}
72+
for i = 1, table.getn(tables) do
73+
local matches = redis.call('KEYS', tables[i])
74+
for j,name in ipairs(matches) do
75+
redis.call('DEL', name)
76+
end
77+
end" 0
78+
}
79+
6580
start() {
6681
debug "Starting ${SERVICE} service..."
6782

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

8499
# start service docker

0 commit comments

Comments
 (0)