Skip to content

Commit

Permalink
[20211] Handle error seen on system where vlan interface map is not p…
Browse files Browse the repository at this point in the history
…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 <sumeenak@microsoft.com>
  • Loading branch information
SuvarnaMeenakshi committed Apr 11, 2022
1 parent 6745a11 commit 41242ac
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 @@ -338,7 +338,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 @@ -50,3 +50,15 @@ def test_init_sync_d_interface_tables(self):
self.assertTrue(if_alias_map == {})
self.assertTrue(if_id_map == {})
self.assertTrue(oid_name_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 41242ac

Please sign in to comment.