From e741c7ca9e898ac65bb3ecaa7de104ab94474f08 Mon Sep 17 00:00:00 2001 From: Volodymyr Samotiy Date: Thu, 13 Aug 2020 02:25:54 +0300 Subject: [PATCH] [PFCWD] Fix issue with "pfcwd show stats" command during SONiC init (#1018) - What I did Fixed issue with pfcwd show stats command during SONiC init. Traceback was returned if DB was not yet initialized which is incorrect. Correct behavior would to rather return empty line if something is not yet ready to be pulled and displayed. - How I did it Returned empty dictionary instead of None if data are still not present in DB. It is because in source code data expected to be as dictionary type but if there is no expected attributes in DB None was returned. Wich is incorrect and caused following exception: 'NoneType' object has no attribute 'keys' Signed-off-by: Volodymyr Samotiy --- pfcwd/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfcwd/main.py b/pfcwd/main.py index 1856ff0f45c6..6f01b63cbf24 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -39,7 +39,7 @@ def cli(): def get_all_queues(db): queue_names = db.get_all(db.COUNTERS_DB, 'COUNTERS_QUEUE_NAME_MAP') - return natsorted(queue_names.keys()) + return natsorted(queue_names.keys() if queue_names else {}) def get_all_ports(db): all_port_names = db.get_all(db.COUNTERS_DB, 'COUNTERS_PORT_NAME_MAP')