Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: not to use blocking get_all() after keys() #255

Merged
merged 1 commit into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sonic_ax_impl/mibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,15 +630,15 @@ def dbs_get_all(dbs, db_name, _hash, *args, **kwargs):
result = {}
# If there are multiple namespaces, _hash might not be
# present in all namespace, ignore if not present in a
# specfic namespace.
# specific namespace.
if len(dbs) > 1:
tmp_kwargs = kwargs.copy()
tmp_kwargs['blocking'] = False
else:
tmp_kwargs = kwargs
for db_conn in dbs:
ns_result = db_conn.get_all(db_name, _hash, *args, **tmp_kwargs)
if ns_result is not None:
if ns_result:
result.update(ns_result)
return result

Expand Down
17 changes: 9 additions & 8 deletions src/sonic_ax_impl/mibs/ietf/rfc1213.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,15 @@ def update_data(self):
ipnstr = routestr[len("ROUTE_TABLE:"):]
if ipnstr == "0.0.0.0/0":
ipn = ipaddress.ip_network(ipnstr)
ent = Namespace.dbs_get_all(self.db_conn, mibs.APPL_DB, routestr, blocking=True)
nexthops = ent["nexthop"]
for nh in nexthops.split(','):
# TODO: if ipn contains IP range, create more sub_id here
sub_id = ip2byte_tuple(ipn.network_address)
self.route_list.append(sub_id)
self.nexthop_map[sub_id] = ipaddress.ip_address(nh).packed
break # Just need the first nexthop
ent = Namespace.dbs_get_all(self.db_conn, mibs.APPL_DB, routestr, blocking=False)
if ent:
nexthops = ent["nexthop"]
for nh in nexthops.split(','):
# TODO: if ipn contains IP range, create more sub_id here
sub_id = ip2byte_tuple(ipn.network_address)
self.route_list.append(sub_id)
self.nexthop_map[sub_id] = ipaddress.ip_address(nh).packed
break # Just need the first nexthop

self.route_list.sort()

Expand Down
2 changes: 1 addition & 1 deletion src/sonic_ax_impl/mibs/ietf/rfc4363.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def update_data(self):
mibs.logger.error("SyncD 'ASIC_DB' includes invalid FDB_ENTRY '{}': {}.".format(fdb_str, e))
continue

ent = Namespace.dbs_get_all(self.db_conn, mibs.ASIC_DB, s, blocking=True)
ent = Namespace.dbs_get_all(self.db_conn, mibs.ASIC_DB, s, blocking=False)
# Example output: oid:0x3a000000000608
bridge_port_id = ent["SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"][6:]
if bridge_port_id not in self.if_bpid_map:
Expand Down