Skip to content

[rfc1213] Handle error seen when interface counter is not available in COUNTERS_DB#351

Merged
SuvarnaMeenakshi merged 1 commit intosonic-net:masterfrom
SuvarnaMeenakshi:1213_exception
May 1, 2025
Merged

[rfc1213] Handle error seen when interface counter is not available in COUNTERS_DB#351
SuvarnaMeenakshi merged 1 commit intosonic-net:masterfrom
SuvarnaMeenakshi:1213_exception

Conversation

@SuvarnaMeenakshi
Copy link
Copy Markdown
Contributor

@SuvarnaMeenakshi SuvarnaMeenakshi commented May 1, 2025

- What I did
Fix to handle error seen:

ERR snmp#snmp-subagent [ax_interface] ERROR: SubtreeMIBEntry.__call__() caught an unexpected exception during _callable_.__call__()#012Traceback (most recent call last):#012  File "/usr/local/lib/python3.11/dist-packages/ax_interface/mib.py", line 248, in __call__#012    return self._callable_.__call__(sub_id, *self._callable_args)#012           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#012  File "/usr/local/lib/python3.11/dist-packages/sonic_ax_impl/mibs/ietf/rfc1213.py", line 414, in get_counter#012    counter_value += self._get_counter(mibs.get_index_from_str(lag_member), table_name)#012TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

Above error can be seen if certain COUNTER is not supported in COUNTERS_DB. The counters present in DbTables is collected and returned in rfc1213 MIB implementation. Certain platform might not support all of these counters and can lead to the above exception.

- How I did it
Added logic to handle scenario where _get_counters returns None for any port-channel member interface.

- How to verify it
Added unit-test.
Verified on platform where "SAI_PORT_STAT_IF_OUT_QLEN" is not available.
Before fix:

docker exec -it snmp snmpwalk -v2c -c <comm> <IP> 1.3.6.1.2.1.2.2.1.21
WARNING snmp#snmp-subagent [sonic_ax_impl] WARNING: SyncD 'COUNTERS_DB' missing attribute ''SAI_PORT_STAT_IF_OUT_QLEN''.
ERR snmp#snmp-subagent [ax_interface] ERROR: SubtreeMIBEntry.__call__() caught an unexpected exception during _callable_.__call__()#012Traceback (most recent call last):#012  File "/usr/local/lib/python3.11/dist-packages/ax_interface/mib.py", line 248, in __call__#012    return self._callable_.__call__(sub_id, *self._callable_args)#012           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#012  File "/usr/local/lib/python3.11/dist-packages/sonic_ax_impl/mibs/ietf/rfc1213.py", line 414, in get_counter#012    counter_value += self._get_counter(mibs.get_index_from_str(lag_member), table_name)#012TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

After fix:

docker exec -it snmp snmpwalk -v2c -c <comm> <IP> 1.3.6.1.2.1.2.2.1.21
WARNING snmp#snmp-subagent [sonic_ax_impl] WARNING: SyncD 'COUNTERS_DB' missing attribute ''SAI_PORT_STAT_IF_OUT_QLEN''.

- Description for the changelog

…n COUNTERS_DB

Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@SuvarnaMeenakshi SuvarnaMeenakshi merged commit 13b975b into sonic-net:master May 1, 2025
5 checks passed
ssithaia-ebay pushed a commit to ssithaia-ebay/sonic-snmpagent that referenced this pull request May 23, 2025
…n COUNTERS_DB (sonic-net#351)

- What I did
Fix to handle error seen:

ERR snmp#snmp-subagent [ax_interface] ERROR: SubtreeMIBEntry.__call__() caught an unexpected exception during _callable_.__call__()#012Traceback (most recent call last):sonic-net#12  File "/usr/local/lib/python3.11/dist-packages/ax_interface/mib.py", line 248, in __call__#012    return self._callable_.__call__(sub_id, *self._callable_args)sonic-net#12           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^sonic-net#12  File "/usr/local/lib/python3.11/dist-packages/sonic_ax_impl/mibs/ietf/rfc1213.py", line 414, in get_counter#012    counter_value += self._get_counter(mibs.get_index_from_str(lag_member), table_name)#012TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'
Above error can be seen if certain COUNTER is not supported in COUNTERS_DB. The counters present in DbTables is collected and returned in rfc1213 MIB implementation. Certain platform might not support all of these counters and can lead to the above exception.

- How I did it
Added logic to handle scenario where _get_counters returns None for any port-channel member interface.

- How to verify it
Added unit-test.
Verified on platform where "SAI_PORT_STAT_IF_OUT_QLEN" is not available.
Before fix:

docker exec -it snmp snmpwalk -v2c -c <comm> <IP> 1.3.6.1.2.1.2.2.1.21
WARNING snmp#snmp-subagent [sonic_ax_impl] WARNING: SyncD 'COUNTERS_DB' missing attribute ''SAI_PORT_STAT_IF_OUT_QLEN''.
ERR snmp#snmp-subagent [ax_interface] ERROR: SubtreeMIBEntry.__call__() caught an unexpected exception during _callable_.__call__()#012Traceback (most recent call last):sonic-net#12  File "/usr/local/lib/python3.11/dist-packages/ax_interface/mib.py", line 248, in __call__#012    return self._callable_.__call__(sub_id, *self._callable_args)sonic-net#12           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^sonic-net#12  File "/usr/local/lib/python3.11/dist-packages/sonic_ax_impl/mibs/ietf/rfc1213.py", line 414, in get_counter#012    counter_value += self._get_counter(mibs.get_index_from_str(lag_member), table_name)#012TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'
After fix:

docker exec -it snmp snmpwalk -v2c -c <comm> <IP> 1.3.6.1.2.1.2.2.1.21
WARNING snmp#snmp-subagent [sonic_ax_impl] WARNING: SyncD 'COUNTERS_DB' missing attribute ''SAI_PORT_STAT_IF_OUT_QLEN''.
@rlhui
Copy link
Copy Markdown

rlhui commented Jun 11, 2025

@arlakshm will we port this?

@rlhui
Copy link
Copy Markdown

rlhui commented Jun 25, 2025

@Javier-Tan can we help back-port this? thx

@rlhui
Copy link
Copy Markdown

rlhui commented Jul 9, 2025

@Javier-Tan reminder on this, thanks

@Javier-Tan
Copy link
Copy Markdown

Javier-Tan commented Jul 10, 2025

@Javier-Tan reminder on this, thanks

Sorry for delay, creating patch for internal-202503

Edit: created

@rlhui rlhui moved this to Done in SONiC Chassis Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants