Skip to content

Commit 1695104

Browse files
ayurkiv-nvdaqiluo-msft
authored andcommitted
[show priority-group drop counters] Remove backup with cached PG drop counters after 'config reload' (#1679)
- What I did Explanation how show/clear counters works: Suppose we got from SDK some count of dropped packets for priority group (№3) per interface (Ehernet4). (for example Ethernet4 PG-3 123 packets) Stats can be shown via show priority-group drop counters Then we run sonic-clear priority-group drop counters. This command will save data "Ethernet4 PG-3 123 packets" to backup. It saved in /tmp/dropstat-{user_id} folder When we run show priority-group drop counters again, script will take data from SDK and data saved from backup. In backup it will find 123. In SDK it may still be number 123 for Ethernet4 (like in backup) or bigger (for example 126.) Our sonic-clear priority-group drop counters command does not change anything in SDK. It just show difference beetwen SDK data and last saved data. So if in SDK data is 123, show priority-group drop counters will show 0 (123 minus 123) - data is cleared If in SDK data is bigger than saved 124, or higher show priority-group drop counters will show 1 (124 minus 123) FIX After config reload all counters drop counters data retrieved from SDK become cleared. All counters become zeros. In this case show priority-group drop counters will show -123 ( 0 (from SDK) minus 123 (saved backup)) So we don't need backup after config reload - How I did it remove /tmp/dropstat-{user_id} folders with counters backup Signed-off-by: Andriy Yurkiv <[email protected]>
1 parent e99a3c5 commit 1695104

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

config/main.py

+5
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,11 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, disable_arp_cach
11121112
if multi_asic.is_multi_asic():
11131113
num_cfg_file += num_asic
11141114

1115+
# Remove cached PG drop counters data
1116+
dropstat_dir_prefix = '/tmp/dropstat'
1117+
command = "rm -rf {}-*".format(dropstat_dir_prefix)
1118+
clicommon.run_command(command, display_cmd=True)
1119+
11151120
# If the user give the filename[s], extract the file names.
11161121
if filename is not None:
11171122
cfg_files = filename.split(',')

tests/pgdropstat_test.py

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import show.main as show
55
import clear.main as clear
6+
import config.main as config
67

78
from click.testing import CliRunner
89

@@ -62,6 +63,20 @@ def executor(self, clear_before_show):
6263
assert result.exit_code == 0
6364
assert result.output == show_output
6465

66+
def test_show_pg_drop_config_reload(self):
67+
runner = CliRunner()
68+
self.test_show_pg_drop_clear()
69+
70+
# simulate 'config reload' to provoke counters recalculation (remove backup from /tmp folder)
71+
result = runner.invoke(config.config.commands["reload"], [ "--no_service_restart", "-y"])
72+
73+
print(result.exit_code)
74+
print(result.output)
75+
76+
assert result.exit_code == 0
77+
78+
self.test_show_pg_drop_show()
79+
6580
@classmethod
6681
def teardown_class(cls):
6782
os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1])

0 commit comments

Comments
 (0)