Commit 13b975b
authored
[rfc1213] Handle error seen when interface counter is not available in COUNTERS_DB (#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):#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)#12 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#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):#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)#12 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#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''.1 parent f55bee8 commit 13b975b
2 files changed
Lines changed: 65 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
414 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
415 | 419 | | |
416 | 420 | | |
417 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
0 commit comments