Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PFCWD] Fix issue with "pfcwd show stats" command during SONiC init #1018

Merged
merged 1 commit into from
Aug 12, 2020

Conversation

volodymyrsamotiy
Copy link
Collaborator

  • Traceback was returned if DB is not yet initialized

Signed-off-by: Volodymyr Samotiy volodymyrs@mellanox.com

- 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'

- How to verify it
Perform any type of reboot or config reload and once switch bootted but not fully initialized execute command pfcwd show stats. No exception or errors should be observed, just empty table.

- Previous command output (if the output of a command-line utility has changed)

root@sonic:/home/admin# pfcwd show stats
Traceback (most recent call last):
  File "/usr/bin/pfcwd", line 12, in <module>
    sys.exit(cli())
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pfcwd/main.py", line 83, in stats
    queues = get_all_queues(db)
  File "/usr/lib/python2.7/dist-packages/pfcwd/main.py", line 44, in get_all_queues
    return natsorted(queue_names.keys())
AttributeError: 'NoneType' object has no attribute 'keys'
root@sonic:/home/admin#

- New command output (if the output of a command-line utility has changed)

root@sonic:/home/admin# pfcwd show stats
  QUEUE    STATUS    STORM DETECTED/RESTORED    TX OK/DROP    RX OK/DROP    TX LAST OK/DROP    RX LAST OK/DROP
-------  --------  -------------------------  ------------  ------------  -----------------  -----------------
root@sonic:/home/admin#

* Traceback was returned if DB is not yet initialized

Signed-off-by: Volodymyr Samotiy <volodymyrs@mellanox.com>
@liat-grozovik
Copy link
Collaborator

retest this please

1 similar comment
@volodymyrsamotiy
Copy link
Collaborator Author

retest this please

@lguohan lguohan merged commit e741c7c into sonic-net:master Aug 12, 2020
abdosi pushed a commit that referenced this pull request Sep 3, 2020
…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>
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
Fix error when running 'show lldp table' or 'show lldp neighbor'
through SSH command. (sonic-net#1067)
[201911]: Multi asic show interface support (sonic-net#1070)
[counterpoll] Add new FC group for port buffer drop counters
(sonic-net#1024)
[201911] show interface portchannel support for Multi ASIC
(sonic-net#1071)
Fix a typo in mellanox_buffer_migrator (sonic-net#1090)
Fix pfcwd stats crash with invalid queue name (sonic-net#1077)
[PFCWD] Fix issue with "pfcwd show stats" command during SONiC init
(sonic-net#1018)
enable watchdog before running platform specific reboot plugin
(sonic-net#1037)
Add namespace of the process in the coredump filename. (sonic-net#1091)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants