From 94d39c37b9ad4e49a9920f3ee98112e8fe34a2f4 Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Mon, 11 Dec 2023 16:33:49 -0500 Subject: [PATCH] Don't scan for posture checks if there are 0 posture checks in the system. Fixes #1576 --- controller/model/edge_service_manager.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/controller/model/edge_service_manager.go b/controller/model/edge_service_manager.go index 0d776731b..378425f96 100644 --- a/controller/model/edge_service_manager.go +++ b/controller/model/edge_service_manager.go @@ -329,6 +329,7 @@ type PolicyPostureChecks struct { func (self *EdgeServiceManager) GetPolicyPostureChecks(identityId, serviceId string) map[string]*PolicyPostureChecks { policyIdToChecks := map[string]*PolicyPostureChecks{} + postureCheckCache := map[string]*PostureCheck{} servicePolicyStore := self.env.GetStores().ServicePolicy @@ -339,6 +340,10 @@ func (self *EdgeServiceManager) GetPolicyPostureChecks(identityId, serviceId str policyTypeSymbol := self.env.GetStores().ServicePolicy.GetSymbol(db.FieldServicePolicyType) _ = self.GetDb().View(func(tx *bbolt.Tx) error { + if !self.env.GetStores().PostureCheck.IterateIds(tx, ast.BoolNodeTrue).IsValid() { + return nil + } + policyCursor := self.env.GetStores().Identity.GetRelatedEntitiesCursor(tx, identityId, db.EntityTypeServicePolicies, true) policyCursor = ast.NewFilteredCursor(policyCursor, func(policyId []byte) bool { return serviceLinks.IsLinked(tx, policyId, []byte(serviceId))