Commit ad302d4
authored
Fix: 'key not found' exception in bgp4.py (sonic-net#192)
**- What I did**
A 'key not found' exception will be raised in bgp4.py if the state for a given neighbor is not found in STATE_DB.
```
ERR snmp#snmp-subagent [ax_interface] ERROR: MIBUpdater.start() caught an unexpected exception during update_data()
#012Traceback (most recent call last):
#12 File "/usr/local/lib/python3.7/dist-packages/ax_interface/mib.py", line 43, in start
#12 self.update_data()#12 File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/vendor/cisco/bgp4.py", line 42, in update_data
#12 state = neigh_info['state']
#12 File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 345, in __getitem__
#12 return _swsscommon.FieldValueMap___getitem__(self, key)
#012IndexError: key not found
```
It is becaues an empty ```dict``` is returned by ```get_all``` when nothing is found for the given key. So check for ```None``` can't detect the error.
**- How I did it**
This commit addressed the issue by checking the key ```state```.
**- How to verify it**
Verified on A7260. No exception is observed after the update.
**- Description for the changelog**
This PR fix exception caused by non existing key.1 parent 59e2a1c commit ad302d4
1 file changed
+2
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
5 | | - | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
| |||
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | | - | |
| 23 | + | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
| |||
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
41 | | - | |
| 39 | + | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
| |||
0 commit comments