Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[debug dump] Missing Dict Key handled in the MatchOptimizer (sonic-ne…
…t#2014) - Why I did The hardcoded delimiter used in the match_optimizer was updated to be assigned dynamically based on the db name provided. Sometimes, the kv-pairs received from match engine may not contain the necessary fields requested and in those cases MatchEngine Optimizer is throwing a KeyError Exception on the missing field. Added Unit tests to cover the scenario Traceback (most recent call last): File "/usr/local/bin/dump", line 8, in <module> sys.exit(dump()) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 764, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 555, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/dump/main.py", line 85, in state collected_info[arg] = obj.execute(params) File "/usr/local/lib/python3.9/dist-packages/dump/plugins/route.py", line 82, in execute self.init_asic_nh() File "/usr/local/lib/python3.9/dist-packages/dump/plugins/route.py", line 142, in init_asic_nh nh_ex.collect() File "/usr/local/lib/python3.9/dist-packages/dump/plugins/route.py", line 211, in collect rif_oid = self.init_asic_next_hop_info(self.rt.nh_id) File "/usr/local/lib/python3.9/dist-packages/dump/plugins/route.py", line 191, in init_asic_next_hop_info ret = self.rt.nhgrp_match_engine.fetch(req) File "/usr/local/lib/python3.9/dist-packages/dump/match_infra.py", line 430, in fetch return self.__mutate_response(ret, fv_requested, ret_just_keys) File "/usr/local/lib/python3.9/dist-packages/dump/match_infra.py", line 389, in __mutate_response new_ret["return_values"][key][field] = key_fv[key][field] KeyError: 'SAI_NEXT_HOP_ATTR_ROUTER_INTERFACE_ID' - How I did it Handled the no-field present case gracefully Signed-off-by: vkarri <vkarri@contoso.com>
- Loading branch information