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

[caclmgrd]: Add infrastructure to support adding feature specific acls #11367

Merged
merged 5 commits into from
Jul 13, 2022

Conversation

SuvarnaMeenakshi
Copy link
Contributor

@SuvarnaMeenakshi SuvarnaMeenakshi commented Jul 6, 2022

Signed-off-by: Suvarna Meenakshi sumeenak@microsoft.com

Why I did it

Add infrastructure to support adding feature specific acls.
If feature specific ACLs has to be added:

if feature_name in self.feature_present and self.feature_present.get('feature_name'):
    add_feature_specific_acls()

How I did it

Add function to get features present in feature table.

How to verify it

unit-test passes.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

ACLs if required.

Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
@@ -201,6 +206,12 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
tcp_flags_str = tcp_flags_str[:-1]
return tcp_flags_str

def update_feature_present(self):
Copy link
Collaborator

@qiluo-msft qiluo-msft Jul 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update_feature_present

Could you add unit tests to cover new code? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added unit-test and mock data for the unit-test.

feature_tb_info = self.config_db_map[DEFAULT_NAMESPACE].get_table(self.FEATURE_TABLE)
if feature_tb_info:
for k, v in feature_tb_info.items():
self.feature_present[k] = True
Copy link
Collaborator

@qiluo-msft qiluo-msft Jul 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feature_present

Seems this is a generic oneshot cache. Suggest leverage common library like cached_property. ref: https://www.geeksforgeeks.org/python-functools-cached_property/ #WontFix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the pointer. Currently, we are updating this feature_present map with the features that are present only once during initialization so it is not repeatedlyinvoked.
Also, if we use cached_property, we will invoke the function once, which could be in per-thread context, which might cause issues. So not using cached_property in this case.

Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
Copy link
Contributor

@abdosi abdosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SuvarnaMeenakshi SuvarnaMeenakshi merged commit 57a07fc into sonic-net:master Jul 13, 2022
@SuvarnaMeenakshi SuvarnaMeenakshi deleted the caclmgrd branch July 13, 2022 17:22
yxieca pushed a commit that referenced this pull request Jul 17, 2022
#11367)

Why I did it
Add infrastructure to support adding feature specific acls.
If feature specific ACLs has to be added:

if feature_name in self.feature_present and self.feature_present.get('feature_name'):
    add_feature_specific_acls()
How I did it
Add function to get features present in feature table.

How to verify it
unit-test passes.
skbarista pushed a commit to skbarista/sonic-buildimage that referenced this pull request Aug 17, 2022
sonic-net#11367)

Why I did it
Add infrastructure to support adding feature specific acls.
If feature specific ACLs has to be added:

if feature_name in self.feature_present and self.feature_present.get('feature_name'):
    add_feature_specific_acls()
How I did it
Add function to get features present in feature table.

How to verify it
unit-test passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants