Skip to content

Commit

Permalink
Handle error seen on system where vlan interface map is not present (s…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
SuvarnaMeenakshi authored Mar 28, 2022
1 parent c6141c7 commit 2151731
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/sonic_ax_impl/mibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,11 @@ def init_sync_d_vlan_tables(db_conn):
:return: tuple(vlan_name_map, oid_sai_map, oid_name_map)
"""

vlan_name_map = port_util.get_vlan_interface_oid_map(db_conn)
vlan_name_map = port_util.get_vlan_interface_oid_map(db_conn, blocking=False)

if not vlan_name_map:
logger.debug("There is no vlan interface map in counters DB")
return {}, {}, {}

logger.debug("Vlan oid map:\n" + pprint.pformat(vlan_name_map, indent=2))

Expand Down
12 changes: 12 additions & 0 deletions tests/test_mibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,15 @@ def test_init_sync_d_queue_tables(self):
self.assertTrue(port_queues_map == {})
self.assertTrue(queue_stat_map == {})
self.assertTrue(port_queue_list_map == {})

@mock.patch('swsssdk.dbconnector.SonicV2Connector.get_all', mock.MagicMock(return_value=({})))
def test_init_sync_d_vlan_tables(self):
db_conn = Namespace.init_namespace_dbs()

vlan_name_map, \
vlan_oid_sai_map, \
vlan_oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_vlan_tables, db_conn)

self.assertTrue(vlan_name_map == {})
self.assertTrue(vlan_oid_sai_map == {})
self.assertTrue(vlan_oid_name_map == {})

0 comments on commit 2151731

Please sign in to comment.