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

[intfutil] set speed to 0 when interface speed is not available #839

Merged
merged 1 commit into from
Mar 17, 2020

Conversation

yxieca
Copy link
Contributor

@yxieca yxieca commented Mar 17, 2020

- What I did

This is not an issue with normal and correct configuration. The
issue was exposed when there is an incorrect configuration, e.g.
contain wrong port names. These wrong port names will still get
populated to the app_db but will not have speed associated.

Lack of speed entry will cause "show interface status" to throw
exception.

Signed-off-by: Ying Xie ying.xie@microsoft.com

- How to verify it
Without change, when speed is not available:
admin@str-dcfx-t1-2-03:~$ show interfaces status
Traceback (most recent call last):
File "/usr/bin/intfutil", line 424, in
main(sys.argv[1:])
File "/usr/bin/intfutil", line 417, in main
interface_stat = IntfStatus(intf_name)
File "/usr/bin/intfutil", line 345, in init
self.portchannel_speed_dict = po_speed_dict(self.po_int_dict, self.appl_db)
File "/usr/bin/intfutil", line 236, in po_speed_dict
temp_speed = int(temp_speed)
TypeError: int() argument must be a string or a number, not 'NoneType'

With change command works fine.

This is not an issue with normal and correct configuration. The
issue was exposed when there is an incorrect configuration, e.g.
contain wrong port names. These wrong port names will still get
populated to the app_db but will not have speed associated.

Lack of speed entry will cause "show interface status" to throw
exception.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
@@ -276,7 +276,7 @@ def po_speed_dict(po_int_dict, appl_db):
elif len(value) > 1:
for intf in value:
temp_speed = appl_db.get(appl_db.APPL_DB, "PORT_TABLE:" + intf, "speed")
temp_speed = int(temp_speed)
temp_speed = int(temp_speed) if temp_speed else 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

processing of the exception should protect from both empty speed and invalid speed string (e.g, 1000o)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolute right.

But I think app_db's speed is populated by SONiC, it could be missing, but shouldn't have format issue. If we did cause such a code bug, I think we should fix the formatting code.

@yxieca yxieca merged commit 4389ffe into sonic-net:master Mar 17, 2020
@yxieca yxieca deleted the intfutil branch March 17, 2020 21:38
abdosi pushed a commit that referenced this pull request Mar 24, 2020
This is not an issue with normal and correct configuration. The
issue was exposed when there is an incorrect configuration, e.g.
contain wrong port names. These wrong port names will still get
populated to the app_db but will not have speed associated.

Lack of speed entry will cause "show interface status" to throw
exception.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
abdosi pushed a commit to abdosi/sonic-utilities that referenced this pull request Aug 4, 2020
…c-net#839)

This is not an issue with normal and correct configuration. The
issue was exposed when there is an incorrect configuration, e.g.
contain wrong port names. These wrong port names will still get
populated to the app_db but will not have speed associated.

Lack of speed entry will cause "show interface status" to throw
exception.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 18, 2022
#### Why I did it
To pick up fixes from submodule sonic-sairedis which include the following fixes:
```
commit 1027eef3a331e84560827c7584ee8009baf434d5 (HEAD -> 202012, origin/202012)
Author: gechiang <62408185+gechiang@users.noreply.github.com>
Date:   Wed Dec 8 03:13:34 2021 -0800

    [202012] Prevent other notification event storms to keep enqueue unchecked and drained all memory that leads to crashing the switch router (sonic-net#976)

commit 94455e50d3444dcd60093b7a39c7f427337a94d2
Author: VenkatCisco <77468614+VenkatCisco@users.noreply.github.com>
Date:   Tue Jun 15 03:23:20 2021 -0700

    Add cisco-8000 checks to syncd_init_common (sonic-net#839)

commit 2df539483ed68519c3c9c6df958d3ed2f31dd629
Author: Kamil Cudnik <kcudnik@gmail.com>
Date:   Mon Dec 6 20:50:23 2021 +0100

    [lgtm] Add gmock libs to lgtm (sonic-net#979)

```
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
[fwutil]: Use overlay driver when mounting next image filesystem (sonic-net#825)
Fix for adding L3 interface to Vlan group (sonic-net#826)Fix for adding L3 interface to Vlan group (sonic-net#826)
[db_migrator]Do DB migration for buffer pool size change on Mellanox platform (sonic-net#833)
explicitly specify command with underscores (sonic-net#846)
[intfutil] set speed to 0 when interface speed is not available (sonic-net#839)
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.

4 participants