Optimze ACL Table/Rule notification handling (#5621)

* Optimze ACL Table/Rule notifcation handling
to loop pop() until empty to consume all the data in a batch

This wau we prevent multiple call to iptable updates

Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>

* Address review comments

Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
This commit is contained in:
abdosi 2020-10-14 08:05:33 -07:00 committed by GitHub
parent 812e1a3489
commit 9094e2176f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -539,7 +539,7 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
# Loop on select to see if any event happen on config db of any namespace # Loop on select to see if any event happen on config db of any namespace
while True: while True:
ctrl_plane_acl_notification = False ctrl_plane_acl_notification = set()
(state, selectableObj) = sel.select(SELECT_TIMEOUT_MS) (state, selectableObj) = sel.select(SELECT_TIMEOUT_MS)
# Continue if select is timeout or selectable object is not return # Continue if select is timeout or selectable object is not return
if state != swsscommon.Select.OBJECT: if state != swsscommon.Select.OBJECT:
@ -550,23 +550,24 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
namespace = redisSelectObj.getDbConnector().getNamespace() namespace = redisSelectObj.getDbConnector().getNamespace()
# Pop data of both Subscriber Table object of namespace that got config db acl table event # Pop data of both Subscriber Table object of namespace that got config db acl table event
for table in config_db_subscriber_table_map[namespace]: for table in config_db_subscriber_table_map[namespace]:
(key, op, fvp) = table.pop() while True:
# Pop of table that does not have data (key, op, fvp) = table.pop()
if key == '': # Pop of table that does not have data so break
continue if key == '':
# ACL Table notification. We will take Control Plane ACTION for any ACL Table Event break
# This can be optimize further but we should not have many acl table set/del events in normal # ACL Table notification. We will take Control Plane ACTION for any ACL Table Event
# scenario # This can be optimize further but we should not have many acl table set/del events in normal
elif acl_rule_table_seprator not in key: # scenario
ctrl_plane_acl_notification = True if acl_rule_table_seprator not in key:
# Check ACL Rule notification and make sure Rule point to ACL Table which is Controlplane ctrl_plane_acl_notification.add(namespace)
else: # Check ACL Rule notification and make sure Rule point to ACL Table which is Controlplane
acl_table = key.split(acl_rule_table_seprator)[0] else:
if self.config_db_map[namespace].get_table(self.ACL_TABLE)[acl_table]["type"] == self.ACL_TABLE_TYPE_CTRLPLANE: acl_table = key.split(acl_rule_table_seprator)[0]
ctrl_plane_acl_notification = True if self.config_db_map[namespace].get_table(self.ACL_TABLE)[acl_table]["type"] == self.ACL_TABLE_TYPE_CTRLPLANE:
ctrl_plane_acl_notification.add(namespace)
# Update the Control Plane ACL of the namespace that got config db acl table/rule event # Update the Control Plane ACL of the namespace that got config db acl table event
if ctrl_plane_acl_notification: for namespace in ctrl_plane_acl_notification:
self.update_control_plane_acls(namespace) self.update_control_plane_acls(namespace)
# ============================= Functions ============================= # ============================= Functions =============================