Skip to content

Commit

Permalink
[PFCWD] Fix issue with "pfcwd show stats" command during SONiC init (s…
Browse files Browse the repository at this point in the history
…onic-net#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 <volodymyrs@mellanox.com>
  • Loading branch information
volodymyrsamotiy authored Aug 12, 2020
1 parent 2d9d00d commit e741c7c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pfcwd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit e741c7c

Please sign in to comment.