From 29d29b94917954f0bbffa11fb1a265c2c26e840c Mon Sep 17 00:00:00 2001 From: Stepan Blyshchak <38952541+stepanblyschak@users.noreply.github.com> Date: Thu, 28 Jul 2022 12:03:22 +0300 Subject: [PATCH] [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 --- .../warmboot-finalizer/finalize-warmboot.sh | 12 ++++-------- files/scripts/swss.sh | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/files/image_config/warmboot-finalizer/finalize-warmboot.sh b/files/image_config/warmboot-finalizer/finalize-warmboot.sh index c4d3338dcc..4125592890 100755 --- a/files/image_config/warmboot-finalizer/finalize-warmboot.sh +++ b/files/image_config/warmboot-finalizer/finalize-warmboot.sh @@ -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/ - fi - done + cache_counters_folder="/host/counters" + if [[ -d $cache_counters_folder ]]; then + mv $cache_counters_folder /tmp/cache + fi } diff --git a/files/scripts/swss.sh b/files/scripts/swss.sh index 9d8f176373..ee30d49cda 100755 --- a/files/scripts/swss.sh +++ b/files/scripts/swss.sh @@ -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(),