From 68127792e0ef2a7f62d82c6b999e496c441a4f84 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Tue, 22 Jan 2019 23:44:53 +0000 Subject: [PATCH 1/2] [caclmgrd] Don't crash if we find empty/null rule_props --- files/image_config/caclmgrd/caclmgrd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/image_config/caclmgrd/caclmgrd b/files/image_config/caclmgrd/caclmgrd index a7ec952ca21f..251af10dac25 100755 --- a/files/image_config/caclmgrd/caclmgrd +++ b/files/image_config/caclmgrd/caclmgrd @@ -182,6 +182,10 @@ class ControlPlaneAclManager(object): acl_rules = {} for ((rule_table_name, rule_id), rule_props) in self._rules_db_info.iteritems(): + if not rule_props: + log_warning("rule_props for rule_id {} empty or null!".format(rule_id)) + continue + if rule_table_name == table_name: acl_rules[rule_props["PRIORITY"]] = rule_props From 739939ad1caa733ce80c584a9f386d3cdc98674b Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 23 Jan 2019 01:29:37 +0000 Subject: [PATCH 2/2] Address review comments --- files/image_config/caclmgrd/caclmgrd | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/files/image_config/caclmgrd/caclmgrd b/files/image_config/caclmgrd/caclmgrd index 251af10dac25..5e8d83074de1 100755 --- a/files/image_config/caclmgrd/caclmgrd +++ b/files/image_config/caclmgrd/caclmgrd @@ -182,12 +182,16 @@ class ControlPlaneAclManager(object): acl_rules = {} for ((rule_table_name, rule_id), rule_props) in self._rules_db_info.iteritems(): - if not rule_props: - log_warning("rule_props for rule_id {} empty or null!".format(rule_id)) - continue - if rule_table_name == table_name: - acl_rules[rule_props["PRIORITY"]] = rule_props + if not rule_props: + log_warning("rule_props for rule_id {} empty or null!".format(rule_id)) + continue + + try: + acl_rules[rule_props["PRIORITY"]] = rule_props + except KeyError: + log_error("rule_props for rule_id {} does not have key 'PRIORITY'!".format(rule_id)) + continue # If we haven't determined the IP version for this ACL table yet, # try to do it now. We determine heuristically based on whether the