From 36e1edc04f92a589cc6bf0d0cd32ee3b02ee2624 Mon Sep 17 00:00:00 2001 From: Jordan Montgomery Date: Thu, 12 Jun 2025 11:39:49 -0400 Subject: [PATCH] Add a comment explaining ordering when disabling policies (#29961) For #29958 Adds a comment to address PR comment in prior PR. --- server/service/osquery.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/service/osquery.go b/server/service/osquery.go index 3d0c34bd81..0e3fa07d39 100644 --- a/server/service/osquery.go +++ b/server/service/osquery.go @@ -811,6 +811,8 @@ func (svc *Service) policyQueriesForHost(ctx context.Context, host *fleet.Host) if !svc.shouldUpdate(policyReportedAt, svc.config.Osquery.PolicyUpdateInterval, host.ID) && !host.RefetchRequested { return nil, false, nil } + // This must come after the check above to avoid unnecessary queries to the database. Most + // requests from live connected hosts will not reach this point disablePolicies, err := svc.disablePoliciesDuringSetupExperience(ctx, host) if err != nil { return nil, false, ctxerr.Wrap(ctx, err, "check if host is in setup experience")