Skip to content

Commit fccb21b

Browse files
[RFC1213]: Initialize lag oid map in reinit_data instead of (sonic-net#232)
- 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.
1 parent 43b5e1a commit fccb21b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/sonic_ax_impl/mibs/ietf/rfc1213.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ def reinit_data(self):
235235
self.rif_port_map, \
236236
self.port_rif_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_rif_tables, self.db_conn)
237237

238+
self.lag_name_if_name_map, \
239+
self.if_name_lag_name_map, \
240+
self.oid_lag_name_map, \
241+
self.lag_sai_map, self.sai_lag_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn)
242+
238243
def update_data(self):
239244
"""
240245
Update redis (caches config)
@@ -246,11 +251,6 @@ def update_data(self):
246251

247252
self.aggregate_counters()
248253

249-
self.lag_name_if_name_map, \
250-
self.if_name_lag_name_map, \
251-
self.oid_lag_name_map, \
252-
self.lag_sai_map, self.sai_lag_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_lag_tables, self.db_conn)
253-
254254
self.if_range = sorted(list(self.oid_name_map.keys()) +
255255
list(self.oid_lag_name_map.keys()) +
256256
list(self.mgmt_oid_name_map.keys()) +

0 commit comments

Comments
 (0)