mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
pass a pointer to config instead of the whole config to goroutines (#6823)
This commit is contained in:
parent
fbbe4bb1e6
commit
780db937de
3 changed files with 11 additions and 11 deletions
|
|
@ -29,7 +29,7 @@ func errHandler(ctx context.Context, logger kitlog.Logger, msg string, err error
|
|||
ctxerr.Handle(ctx, err)
|
||||
}
|
||||
|
||||
func cronDB(ctx context.Context, ds fleet.Datastore, logger kitlog.Logger, identifier string, config config.FleetConfig, license *fleet.LicenseInfo, enrollHostLimiter fleet.EnrollHostLimiter) {
|
||||
func cronDB(ctx context.Context, ds fleet.Datastore, logger kitlog.Logger, identifier string, config *config.FleetConfig, license *fleet.LicenseInfo, enrollHostLimiter fleet.EnrollHostLimiter) {
|
||||
logger = kitlog.With(logger, "cron", lockKeyLeader)
|
||||
|
||||
ticker := time.NewTicker(10 * time.Second)
|
||||
|
|
@ -95,7 +95,7 @@ func cronDB(ctx context.Context, ds fleet.Datastore, logger kitlog.Logger, ident
|
|||
|
||||
// NOTE(mna): this is not a route from the fleet server (not in server/service/handler.go) so it
|
||||
// will not automatically support the /latest/ versioning. Leaving it as /v1/ for that reason.
|
||||
err = trySendStatistics(ctx, ds, fleet.StatisticsFrequency, "https://fleetdm.com/api/v1/webhooks/receive-usage-analytics", config, license)
|
||||
err = trySendStatistics(ctx, ds, fleet.StatisticsFrequency, "https://fleetdm.com/api/v1/webhooks/receive-usage-analytics", *config, license)
|
||||
if err != nil {
|
||||
errHandler(ctx, logger, "sending statistics", err)
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ func cronVulnerabilities(
|
|||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
identifier string,
|
||||
config config.VulnerabilitiesConfig,
|
||||
config *config.VulnerabilitiesConfig,
|
||||
) {
|
||||
logger = kitlog.With(logger, "cron", lockKeyVulnerabilities)
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ func checkOvalVulnerabilities(
|
|||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
vulnPath string,
|
||||
config config.VulnerabilitiesConfig,
|
||||
config *config.VulnerabilitiesConfig,
|
||||
collectVulns bool,
|
||||
) []fleet.SoftwareVulnerability {
|
||||
if config.DisableDataSync {
|
||||
|
|
@ -377,7 +377,7 @@ func checkNVDVulnerabilities(
|
|||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
vulnPath string,
|
||||
config config.VulnerabilitiesConfig,
|
||||
config *config.VulnerabilitiesConfig,
|
||||
collectVulns bool,
|
||||
) []fleet.SoftwareVulnerability {
|
||||
if !config.DisableDataSync {
|
||||
|
|
|
|||
|
|
@ -691,9 +691,9 @@ func runCrons(
|
|||
// StartCollectors starts a goroutine per collector, using ctx to cancel.
|
||||
task.StartCollectors(ctx, kitlog.With(logger, "cron", "async_task"))
|
||||
|
||||
go cronDB(ctx, ds, kitlog.With(logger, "cron", "cleanups"), ourIdentifier, config, license, enrollHostLimiter)
|
||||
go cronDB(ctx, ds, kitlog.With(logger, "cron", "cleanups"), ourIdentifier, &config, license, enrollHostLimiter)
|
||||
go cronVulnerabilities(
|
||||
ctx, ds, kitlog.With(logger, "cron", "vulnerabilities"), ourIdentifier, config.Vulnerabilities)
|
||||
ctx, ds, kitlog.With(logger, "cron", "vulnerabilities"), ourIdentifier, &config.Vulnerabilities)
|
||||
go cronWebhooks(ctx, ds, kitlog.With(logger, "cron", "webhooks"), ourIdentifier, failingPoliciesSet, 1*time.Hour)
|
||||
go cronWorker(ctx, ds, kitlog.With(logger, "cron", "worker"), ourIdentifier)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ func TestCronVulnerabilitiesCreatesDatabasesPath(t *testing.T) {
|
|||
|
||||
// We cancel right away so cronsVulnerailities finishes. The logic we are testing happens before the loop starts
|
||||
cancelFunc()
|
||||
cronVulnerabilities(ctx, ds, kitlog.NewNopLogger(), "AAA", config)
|
||||
cronVulnerabilities(ctx, ds, kitlog.NewNopLogger(), "AAA", &config)
|
||||
|
||||
require.DirExists(t, vulnPath)
|
||||
}
|
||||
|
|
@ -249,7 +249,7 @@ func TestCronVulnerabilitiesAcceptsExistingDbPath(t *testing.T) {
|
|||
|
||||
// We cancel right away so cronsVulnerailities finishes. The logic we are testing happens before the loop starts
|
||||
cancelFunc()
|
||||
cronVulnerabilities(ctx, ds, logger, "AAA", config)
|
||||
cronVulnerabilities(ctx, ds, logger, "AAA", &config)
|
||||
|
||||
require.Contains(t, buf.String(), `"waiting":"on ticker"`)
|
||||
}
|
||||
|
|
@ -286,7 +286,7 @@ func TestCronVulnerabilitiesQuitsIfErrorVulnPath(t *testing.T) {
|
|||
|
||||
// We cancel right away so cronsVulnerailities finishes. The logic we are testing happens before the loop starts
|
||||
cancelFunc()
|
||||
cronVulnerabilities(ctx, ds, logger, "AAA", config)
|
||||
cronVulnerabilities(ctx, ds, logger, "AAA", &config)
|
||||
|
||||
require.Contains(t, buf.String(), `"databases-path":"creation failed, returning"`)
|
||||
}
|
||||
|
|
@ -320,7 +320,7 @@ func TestCronVulnerabilitiesSkipCreationIfStatic(t *testing.T) {
|
|||
|
||||
// We cancel right away so cronsVulnerailities finishes. The logic we are testing happens before the loop starts
|
||||
cancelFunc()
|
||||
cronVulnerabilities(ctx, ds, logger, "AAA", config)
|
||||
cronVulnerabilities(ctx, ds, logger, "AAA", &config)
|
||||
|
||||
require.NoDirExists(t, vulnPath)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue