[port_util] Fix issue: port_util.get_vlan_interface_oid_map should not raise exception when DB has not RIF data#117
Conversation
…t raise exception when DB has not RIF data
efe387a to
9beb381
Compare
|
@qiluo-msft could you please help to signoff? |
|
Hi @qiluo-msft , could you please review and sign-off? |
|
Hi @qiluo-msft - Can you please direct this PR to the relevant maintainer ? |
|
@qiluo-msft due to limited permission please add a label of bug as well as requested for 202111 |
you can add a new parameter Change the internal blocking accordingly. No need to check The benefit is to keep old behavior, and allow client code to change behavior case by case. In reply to: 1067627217 Refers to: src/swsssdk/port_util.py:162 in 9beb381. [](commit_id = 9beb381, deletion_comment = False) |
Hi @qiluo-msft , I would like to confirm your comment here:
def get_vlan_interface_oid_map(db, blocking=True):
...
Correct? |
|
|
@mlok-nokia - fyi |
|
@Junchao-Mellanox created snmp PR sonic-net/sonic-snmpagent#246, depends on this PR. |
|
Yes. In reply to: 1068646058 |
049d4cc
|
I removed previous added unit test case as this change is hard to be covered by unit test. |
|
@qiluo-msft could you please review and sign off? |
|
/azpw run Azure.sonic-py-swsssdk |
|
/AzurePipelines run Azure.sonic-py-swsssdk |
|
Commenter does not have sufficient privileges for PR 117 in repo Azure/sonic-py-swsssdk |
|
Hi @qiluo-msft , I run the build locally and cannot reproduce the build failure. Could you please help take a look? |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@Junchao-Mellanox We recently add coverage >= 50% enforcement to most of the repos. Could you add a unit test to coverage the missing lines? https://dev.azure.com/mssonic/build/_build/results?buildId=82325&view=codecoverage-tab |
…py-swsssdk into fix-get-vlan-oid
|
Hi @qiluo-msft , could you please review and sign off? |
|
@qiluo-msft - There is no 202111 branch for this repository. Is there a plan to open one ? |
…t raise exception when DB has not RIF data (#117) **Why I did this?** port_util.get_vlan_interface_oid_map would raise exception when there is no RIF configured, and it would causes snmpagent not work. This PR is to fix it. ``` #012Traceback (most recent call last): #012File "/usr/local/lib/python3.7/dist-packages/ax_interface/mib.py", line 37, in start #12 self.reinit_data()#12 File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/ietf/rfc1213.py", line 233, in reinit_data #12 self.vlan_oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_vlan_tables, self.db_conn) #12 File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/__init__.py", line 651, in get_sync_d_from_all_namespace #12 ns_tuple = per_namespace_func(db_conn) #12 File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/__init__.py", line 341, in init_sync_d_vlan_tables #12 vlan_name_map = port_util.get_vlan_interface_oid_map(db_conn) #12 File "/usr/local/lib/python3.7/dist-packages/swsssdk/port_util.py", line 167, in get_vlan_interface_oid_map #12 rif_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_RIF_NAME_MAP', blocking=True) #12 File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 1751, in get_all #12 return dict(super(SonicV2Connector, self).get_all(db_name, _hash, blocking)) #12 File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 1708, in get_all #12 return _swsscommon.SonicV2Connector_Native_get_all(self, db_name, _hash, blocking) #012RuntimeError: Key '{COUNTERS_RIF_NAME_MAP}' unavailable in database '{COUNTERS_DB}' ``` **How I did this:** check redis key exists first before calling get_all.
…246) fixes sonic-net/sonic-buildimage#9996 Handle error seen on system where vlan interface map is not present. This change requires: sonic-net/sonic-py-swsssdk#117 On chassis platform, on supervisor there are not ports available in config_db. So, there is no vlan interface map in counters db, which causes this error in syslog: ERROR: MIBUpdater.start() caught an unexpected exception during update_data(). RuntimeError: Key '{COUNTERS_RIF_NAME_MAP}' unavailable in database '{COUNTERS_DB}' - How I did it Return empty dict if vlan interface map is not present in DB.
…resent fixes sonic-net/sonic-buildimage#9996 Handle error seen on system where vlan interface map is not present. This change requires: sonic-net/sonic-py-swsssdk#117 On chassis platform, on supervisor there are not ports available in config_db. So, there is no vlan interface map in counters db, which causes this error in syslog: ERROR: MIBUpdater.start() caught an unexpected exception during update_data(). RuntimeError: Key '{COUNTERS_RIF_NAME_MAP}' unavailable in database '{COUNTERS_DB}' - How I did it Return empty dict if vlan interface map is not present in DB. (cherry picked from commit 2151731) Signed-off-by: Suvarna Meenakshi <[email protected]>
…present (#252) - What I did cherrypick of: #246 fixes sonic-net/sonic-buildimage#9996 Handle error seen on system where vlan interface map is not present. This change requires: sonic-net/sonic-py-swsssdk#117 On chassis platform, on supervisor there are not ports available in config_db. So, there is no vlan interface map in counters db, which causes this error in syslog: 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 37, in start#012 self.reinit_data()#12 File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/ietf/rfc1213.py", line 233, in reinit_data#012 self.vlan_oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_vlan_tables, self.db_conn)#12 File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/__init__.py", line 649, in get_sync_d_from_all_namespace#012 ns_tuple = per_namespace_func(db_conn)#12 File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/__init__.py", line 339, in init_sync_d_vlan_tables#012 vlan_name_map = port_util.get_vlan_interface_oid_map(db_conn)#12 File "/usr/local/lib/python3.7/dist-packages/swsssdk/port_util.py", line 167, in get_vlan_interface_oid_map#012 rif_name_map = db.get_all('COUNTERS_DB', 'COUNTERS_RIF_NAME_MAP', blocking=True)#12 File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 1751, in get_all#012 return dict(super(SonicV2Connector, self).get_all(db_name, _hash, blocking))#12 File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 1708, in get_all#012 return _swsscommon.SonicV2Connector_Native_get_all(self, db_name, _hash, blocking)#012RuntimeError: Key '{COUNTERS_RIF_NAME_MAP}' unavailable in database '{COUNTERS_DB}' - How I did it Return empty dict if vlan interface map is not present in DB. - How to verify it With this fix, no error in syslog message. Able to execute other MIB queries on supervisor. UT passes.
…onic-net#246) fixes sonic-net/sonic-buildimage#9996 Handle error seen on system where vlan interface map is not present. This change requires: sonic-net/sonic-py-swsssdk#117 On chassis platform, on supervisor there are not ports available in config_db. So, there is no vlan interface map in counters db, which causes this error in syslog: ERROR: MIBUpdater.start() caught an unexpected exception during update_data(). RuntimeError: Key '{COUNTERS_RIF_NAME_MAP}' unavailable in database '{COUNTERS_DB}' - How I did it Return empty dict if vlan interface map is not present in DB.
Why I did this?
port_util.get_vlan_interface_oid_map would raise exception when there is no RIF configured, and it would causes snmpagent not work. This PR is to fix it.
How I did this:
check redis key exists first before calling get_all.