From 027dffee836866bb4b6cadd56fc9cf579726cfc4 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Mon, 12 Jul 2021 09:52:19 -0700 Subject: [PATCH] Fix: SonicV2Connector behavior change: get_all will return empty dict if (#226) the hash does not exist in Redis - What I did Fixes Azure/sonic-buildimage#8140 ref: swsssdk implementation returns None, and the library will be deprecated libswsscommon implementation returns empty dict - How I did it Relax the condition check to accept both representations - How to verify it Unit test Signed-off-by: Qi Luo --- src/sonic_ax_impl/mibs/ietf/rfc1213.py | 2 +- src/sonic_ax_impl/mibs/ietf/rfc4292.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic_ax_impl/mibs/ietf/rfc1213.py b/src/sonic_ax_impl/mibs/ietf/rfc1213.py index 0b8b69ff0..a91a1aee0 100644 --- a/src/sonic_ax_impl/mibs/ietf/rfc1213.py +++ b/src/sonic_ax_impl/mibs/ietf/rfc1213.py @@ -78,7 +78,7 @@ def _update_from_db(self): neigh_str = neigh_key db_index = self.neigh_key_list[neigh_key] neigh_info = self.db_conn[db_index].get_all(mibs.APPL_DB, neigh_key, blocking=False) - if neigh_info is None: + if not neigh_info: continue ip_family = neigh_info['family'] if ip_family == "IPv4": diff --git a/src/sonic_ax_impl/mibs/ietf/rfc4292.py b/src/sonic_ax_impl/mibs/ietf/rfc4292.py index de75c05cf..ea5965e6e 100644 --- a/src/sonic_ax_impl/mibs/ietf/rfc4292.py +++ b/src/sonic_ax_impl/mibs/ietf/rfc4292.py @@ -65,7 +65,7 @@ def update_data(self): continue port_table = multi_asic.get_port_table_for_asic(db_conn.namespace) ent = db_conn.get_all(mibs.APPL_DB, route_str, blocking=False) - if ent is None: + if not ent: continue nexthops = ent["nexthop"] ifnames = ent["ifname"]