Skip to content

Commit

Permalink
[RFC1213]: Initialize lag oid map in reinit_data instead of (#232)
Browse files Browse the repository at this point in the history
- What I did
Initialize lag oid map in reinit_data instead of
updating in update_data. Updating lag oid map in update_data
can cause descrepancy as interface oid map is updated in
reinit_data.

There could be a scenario when lag oid map has lag oids updated in update_data but interfaces oid map is not updated as interfaces oid map is updated in reinit_data. When SNMP service comes up, there could be a short instance of time when interfaces oid map (oid_sai_map) is empty or not complete but lag oid map (oid_lag_name_map) is updated with lag oids and lag members. At this short span, if a SNMP query is done to get interfaces counters, current code will try to get LAG counters and will fail at https://github.com/Azure/sonic-snmpagent/blob/master/src/sonic_ax_impl/mibs/ietf/rfc1213.py#L383 when trying to get oid of lag members' oid. This can lead to key error : sai_id = self.oid_sai_map[oid]#012KeyError.
This change is to avoid this scenario.

- How I did it
init_sync_d_lag_tables in reinit_data instead of invoking in update_data.

- How to verify it
unit-test pass.
SNMP walk of interface MIB output is complete.
  • Loading branch information
SuvarnaMeenakshi authored Aug 30, 2021
1 parent 43b5e1a commit fccb21b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/sonic_ax_impl/mibs/ietf/rfc1213.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ def reinit_data(self):
self.rif_port_map, \
self.port_rif_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_rif_tables, self.db_conn)

self.lag_name_if_name_map, \
self.if_name_lag_name_map, \
self.oid_lag_name_map, \
self.lag_sai_map, self.sai_lag_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn)

def update_data(self):
"""
Update redis (caches config)
Expand All @@ -246,11 +251,6 @@ def update_data(self):

self.aggregate_counters()

self.lag_name_if_name_map, \
self.if_name_lag_name_map, \
self.oid_lag_name_map, \
self.lag_sai_map, self.sai_lag_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn)

self.if_range = sorted(list(self.oid_name_map.keys()) +
list(self.oid_lag_name_map.keys()) +
list(self.mgmt_oid_name_map.keys()) +
Expand Down

0 comments on commit fccb21b

Please sign in to comment.