[swss.sh] clear counters cache folder on swss cold/fast reload (#11244)

A change in sonic-utilities makes all cache files be saved into a
/tmp/cache. On swss restart this cache has to be removed in case swss
starts in cold or fast mode. A related cache restoration in the warmboot
finalizer script is also updated to use new location.

- Why I did it
To fix #9817. Clear the cache directory on swss.sh except for warm start.
Also, adopted finalize-warmboot script to take the cache directory.

- How I did it
A change in sonic-utilities makes all cache files be saved into a /tmp/cache. On swss restart this cache has to be removed in case swss starts in cold or fast mode. A related cache restoration in the warmboot finalizer script is also updated to use new location.

- How to verify it
Run togather with Azure/sonic-utilities#2232. Verify counters cache is removed on config reload, cold/fast reboots, swss restart.

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
This commit is contained in:
Stepan Blyshchak 2022-07-28 12:03:22 +03:00 committed by Ying Xie
parent 0b4e8f77f2
commit 29d29b9491
2 changed files with 5 additions and 8 deletions

View File

@ -109,14 +109,10 @@ function restore_counters_folder()
{
debug "Restoring counters folder after warmboot..."
modules=("portstat-0" "dropstat" "pfcstat-0" "queuestat-0" "intfstat-0")
for module in ${modules[@]}
do
statfile="/host/counters/$module"
if [[ -d $statfile ]]; then
mv $statfile /tmp/
cache_counters_folder="/host/counters"
if [[ -d $cache_counters_folder ]]; then
mv $cache_counters_folder /tmp/cache
fi
done
}

View File

@ -178,6 +178,7 @@ start() {
$SONIC_DB_CLI RESTAPI_DB FLUSHDB
clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*', 'FG_ROUTE_TABLE*', 'BUFFER_POOL*', 'BUFFER_PROFILE*', 'MUX_CABLE_TABLE*', 'ADVERTISE_NETWORK_TABLE*', 'VXLAN_TUNNEL_TABLE*', 'MACSEC_PORT_TABLE*', 'MACSEC_INGRESS_SA_TABLE*', 'MACSEC_EGRESS_SA_TABLE*', 'MACSEC_INGRESS_SC_TABLE*', 'MACSEC_EGRESS_SC_TABLE*'"
$SONIC_DB_CLI APPL_STATE_DB FLUSHDB
rm -rf /tmp/cache
fi
# On supervisor card, skip starting asic related services here. In wait(),