From 7df8196abafa31ca0f35a30687e4c057deadc763 Mon Sep 17 00:00:00 2001 From: abhishek9686 Date: Wed, 27 Nov 2024 12:28:08 +0400 Subject: [PATCH 1/2] initiliase acl cache --- logic/acls.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/logic/acls.go b/logic/acls.go index 8863ce86d..6a99fb36c 100644 --- a/logic/acls.go +++ b/logic/acls.go @@ -18,6 +18,11 @@ var ( aclCacheMap = make(map[string]models.Acl) ) +func init() { + // load acls into cache + _ = listAcls() +} + // CreateDefaultAclNetworkPolicies - create default acl network policies func CreateDefaultAclNetworkPolicies(netID models.NetworkID) { if netID.String() == "" { From 698032a4dc78e26eb1399d8e062940fa058cfafb Mon Sep 17 00:00:00 2001 From: abhishek9686 Date: Wed, 27 Nov 2024 12:57:48 +0400 Subject: [PATCH 2/2] load acls into cache --- logic/acls.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/logic/acls.go b/logic/acls.go index 6a99fb36c..4cc887833 100644 --- a/logic/acls.go +++ b/logic/acls.go @@ -18,11 +18,6 @@ var ( aclCacheMap = make(map[string]models.Acl) ) -func init() { - // load acls into cache - _ = listAcls() -} - // CreateDefaultAclNetworkPolicies - create default acl network policies func CreateDefaultAclNetworkPolicies(netID models.NetworkID) { if netID.String() == "" { @@ -177,6 +172,9 @@ func InsertAcl(a models.Acl) error { func GetAcl(aID string) (models.Acl, error) { a := models.Acl{} if servercfg.CacheEnabled() { + if len(aclCacheMap) == 0 { + _ = listAcls() + } var ok bool a, ok = getAclFromCache(aID) if ok {