mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Fixing code review comments. (#17240)
Fixing code review comments from https://github.com/fleetdm/fleet/pull/16855 Also, moving `CleanupDistributedQueryCampaigns` back to once an hour, so that it is not disabled.
This commit is contained in:
parent
f36b7d4d6d
commit
22dd392da7
2 changed files with 16 additions and 12 deletions
|
|
@ -705,7 +705,6 @@ func newCleanupsAndAggregationSchedule(
|
|||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
lq fleet.LiveQueryStore,
|
||||
logger kitlog.Logger,
|
||||
enrollHostLimiter fleet.EnrollHostLimiter,
|
||||
config *config.FleetConfig,
|
||||
|
|
@ -721,6 +720,13 @@ func newCleanupsAndAggregationSchedule(
|
|||
schedule.WithAltLockID("leader"),
|
||||
schedule.WithLogger(kitlog.With(logger, "cron", name)),
|
||||
// Run cleanup jobs first.
|
||||
schedule.WithJob(
|
||||
"distributed_query_campaigns",
|
||||
func(ctx context.Context) error {
|
||||
_, err := ds.CleanupDistributedQueryCampaigns(ctx, time.Now().UTC())
|
||||
return err
|
||||
},
|
||||
),
|
||||
schedule.WithJob(
|
||||
"incoming_hosts",
|
||||
func(ctx context.Context) error {
|
||||
|
|
@ -846,16 +852,16 @@ func newFrequentCleanupsSchedule(
|
|||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
// Using leader for the lock to be backwards compatilibity with old deployments.
|
||||
schedule.WithAltLockID("leader"),
|
||||
schedule.WithAltLockID("leader_frequent_cleanups"),
|
||||
schedule.WithLogger(kitlog.With(logger, "cron", name)),
|
||||
// Run cleanup jobs first.
|
||||
schedule.WithJob(
|
||||
"distributed_query_campaigns",
|
||||
"redis_live_queries",
|
||||
func(ctx context.Context) error {
|
||||
_, err := ds.CleanupDistributedQueryCampaigns(ctx, time.Now().UTC())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// It's necessary to avoid lingering live queries in case of:
|
||||
// - (Unknown) bug in the implementation, or,
|
||||
// - Redis is so overloaded already that the lq.StopQuery in svc.CompleteCampaign fails to execute, or,
|
||||
// - MySQL is so overloaded that ds.SaveDistributedQueryCampaign in svc.CompleteCampaign fails to execute.
|
||||
names, err := lq.LoadActiveQueryNames()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -865,10 +871,8 @@ func newFrequentCleanupsSchedule(
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := lq.CleanupInactiveQueries(ctx, completed); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
err = lq.CleanupInactiveQueries(ctx, completed)
|
||||
return err
|
||||
},
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -697,7 +697,7 @@ the way that the Fleet server works.
|
|||
commander = apple_mdm.NewMDMAppleCommander(mdmStorage, mdmPushService)
|
||||
}
|
||||
return newCleanupsAndAggregationSchedule(
|
||||
ctx, instanceID, ds, liveQueryStore, logger, redisWrapperDS, &config, commander,
|
||||
ctx, instanceID, ds, logger, redisWrapperDS, &config, commander,
|
||||
)
|
||||
},
|
||||
); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue