Changes needed before gokit/log to slog transition. (#39527)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #38889 PLEASE READ BELOW before looking at file changes Before converting individual files/packages to slog, we generally need to make these 2 changes to make the conversion easier: - Replace uses of `kitlog.With` since they are not fully compatible with our kitlog adapter - Directly use the kitlog adapter logger type instead of the kitlog interface, which will let us have direct access to the underlying slog logger: `*logging.Logger` Note: that I did not replace absolutely all uses of `kitlog.Logger`, but I did remove all uses of `kitlog.With` except for these due to complexity: - server/logging/filesystem.go and the other log writers (webhook, firehose, kinesis, lambda, pubsub, nats) - server/datastore/mysql/nanomdm_storage.go (adapter pattern) - server/vulnerabilities/nvd/* (cascades to CLI tools) - server/service/osquery_utils/queries.go (callback type signatures cascade broadly) - cmd/maintained-apps/ (standalone, so can be transitioned later all at once) Most of the changes in this PR follow these patterns: - `kitlog.Logger` type → `*logging.Logger` - `kitlog.With(logger, ...)` → `logger.With(...)` - `kitlog.NewNopLogger() → logging.NewNopLogger()`, including similar variations such as `logging.NewLogfmtLogger(w)` and `logging.NewJSONLogger(w)` - removed many now-unused kitlog imports Unique changes that the PR review should focus on: - server/platform/logging/kitlog_adapter.go: Core adapter changes - server/platform/logging/logging.go: New convenience functions - server/service/integration_logger_test.go: Test changes for slog # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. - Was added in previous PR ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Migrated the codebase to a unified internal structured logging system for more consistent, reliable logs and observability. * No user-facing functionality changed; runtime behavior and APIs remain compatible. * **Tests** * Updated tests to use the new logging helpers to ensure consistent test logging and validation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
+78
-78
@@ -30,6 +30,7 @@ import (
|
||||
"github.com/fleetdm/fleet/v4/server/mdm/assets"
|
||||
maintained_apps "github.com/fleetdm/fleet/v4/server/mdm/maintainedapps"
|
||||
"github.com/fleetdm/fleet/v4/server/mdm/nanodep/godep"
|
||||
"github.com/fleetdm/fleet/v4/server/platform/logging"
|
||||
"github.com/fleetdm/fleet/v4/server/policies"
|
||||
"github.com/fleetdm/fleet/v4/server/service"
|
||||
"github.com/fleetdm/fleet/v4/server/service/externalsvc"
|
||||
@@ -43,11 +44,10 @@ import (
|
||||
"github.com/fleetdm/fleet/v4/server/vulnerabilities/utils"
|
||||
"github.com/fleetdm/fleet/v4/server/webhooks"
|
||||
"github.com/fleetdm/fleet/v4/server/worker"
|
||||
kitlog "github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
)
|
||||
|
||||
func errHandler(ctx context.Context, logger kitlog.Logger, msg string, err error) {
|
||||
func errHandler(ctx context.Context, logger *logging.Logger, msg string, err error) {
|
||||
level.Error(logger).Log("msg", msg, "err", err)
|
||||
ctxerr.Handle(ctx, err)
|
||||
}
|
||||
@@ -56,12 +56,12 @@ func newVulnerabilitiesSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
config *config.VulnerabilitiesConfig,
|
||||
) (*schedule.Schedule, error) {
|
||||
const name = string(fleet.CronVulnerabilities)
|
||||
interval := config.Periodicity
|
||||
vulnerabilitiesLogger := kitlog.With(logger, "cron", name)
|
||||
vulnerabilitiesLogger := logger.With("cron", name)
|
||||
|
||||
var options []schedule.Option
|
||||
|
||||
@@ -80,7 +80,7 @@ func newVulnerabilitiesSchedule(
|
||||
func cronVulnerabilities(
|
||||
ctx context.Context,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
config *config.VulnerabilitiesConfig,
|
||||
) error {
|
||||
if config == nil {
|
||||
@@ -115,7 +115,7 @@ func cronVulnerabilities(
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateVulnHostCounts(ctx context.Context, ds fleet.Datastore, logger kitlog.Logger, maxConcurrency int) error {
|
||||
func updateVulnHostCounts(ctx context.Context, ds fleet.Datastore, logger *logging.Logger, maxConcurrency int) error {
|
||||
// Prevent invalid values for max concurrency
|
||||
if maxConcurrency <= 0 {
|
||||
level.Info(logger).Log("msg", "invalid maxConcurrency value provided, setting value to 1", "providedValue", maxConcurrency)
|
||||
@@ -136,7 +136,7 @@ func updateVulnHostCounts(ctx context.Context, ds fleet.Datastore, logger kitlog
|
||||
func scanVulnerabilities(
|
||||
ctx context.Context,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
config *config.VulnerabilitiesConfig,
|
||||
appConfig *fleet.AppConfig,
|
||||
vulnPath string,
|
||||
@@ -231,7 +231,7 @@ func scanVulnerabilities(
|
||||
if err := webhooks.TriggerVulnerabilitiesWebhook(
|
||||
ctx,
|
||||
ds,
|
||||
kitlog.With(logger, "webhook", "vulnerabilities"),
|
||||
logger.With("webhook", "vulnerabilities"),
|
||||
args,
|
||||
mapper,
|
||||
); err != nil {
|
||||
@@ -243,7 +243,7 @@ func scanVulnerabilities(
|
||||
if err := worker.QueueJiraVulnJobs(
|
||||
ctx,
|
||||
ds,
|
||||
kitlog.With(logger, "jira", "vulnerabilities"),
|
||||
logger.With("jira", "vulnerabilities"),
|
||||
recentV,
|
||||
matchingMeta,
|
||||
); err != nil {
|
||||
@@ -255,7 +255,7 @@ func scanVulnerabilities(
|
||||
if err := worker.QueueZendeskVulnJobs(
|
||||
ctx,
|
||||
ds,
|
||||
kitlog.With(logger, "zendesk", "vulnerabilities"),
|
||||
logger.With("zendesk", "vulnerabilities"),
|
||||
recentV,
|
||||
matchingMeta,
|
||||
); err != nil {
|
||||
@@ -274,7 +274,7 @@ func scanVulnerabilities(
|
||||
func checkCustomVulnerabilities(
|
||||
ctx context.Context,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
collectVulns bool,
|
||||
startTime time.Time,
|
||||
) []fleet.SoftwareVulnerability {
|
||||
@@ -295,7 +295,7 @@ func checkCustomVulnerabilities(
|
||||
func checkWinVulnerabilities(
|
||||
ctx context.Context,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
vulnPath string,
|
||||
config *config.VulnerabilitiesConfig,
|
||||
collectVulns bool,
|
||||
@@ -336,7 +336,7 @@ func checkWinVulnerabilities(
|
||||
"found new", len(r))
|
||||
results = append(results, r...)
|
||||
if err != nil {
|
||||
errHandler(ctx, kitlog.With(logger, "os name", o.Name, "display version", o.DisplayVersion), "analyzing hosts for Windows vulnerabilities", err)
|
||||
errHandler(ctx, logger.With("os name", o.Name, "display version", o.DisplayVersion), "analyzing hosts for Windows vulnerabilities", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,7 +347,7 @@ func checkWinVulnerabilities(
|
||||
func checkOvalVulnerabilities(
|
||||
ctx context.Context,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
vulnPath string,
|
||||
config *config.VulnerabilitiesConfig,
|
||||
collectVulns bool,
|
||||
@@ -399,7 +399,7 @@ func checkOvalVulnerabilities(
|
||||
func checkGovalDictionaryVulnerabilities(
|
||||
ctx context.Context,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
vulnPath string,
|
||||
config *config.VulnerabilitiesConfig,
|
||||
collectVulns bool,
|
||||
@@ -450,7 +450,7 @@ func checkGovalDictionaryVulnerabilities(
|
||||
func checkNVDVulnerabilities(
|
||||
ctx context.Context,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
vulnPath string,
|
||||
config *config.VulnerabilitiesConfig,
|
||||
collectVulns bool,
|
||||
@@ -494,7 +494,7 @@ func checkNVDVulnerabilities(
|
||||
func checkMacOfficeVulnerabilities(
|
||||
ctx context.Context,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
vulnPath string,
|
||||
config *config.VulnerabilitiesConfig,
|
||||
collectVulns bool,
|
||||
@@ -528,7 +528,7 @@ func newAutomationsSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
intervalReload time.Duration,
|
||||
failingPoliciesSet fleet.FailingPolicySet,
|
||||
) (*schedule.Schedule, error) {
|
||||
@@ -543,7 +543,7 @@ func newAutomationsSchedule(
|
||||
s := schedule.New(
|
||||
// TODO(sarah): Reconfigure settings so automations interval doesn't reside under webhook settings
|
||||
ctx, name, instanceID, appConfig.WebhookSettings.Interval.ValueOr(defaultInterval), ds, ds,
|
||||
schedule.WithLogger(kitlog.With(logger, "cron", name)),
|
||||
schedule.WithLogger(logger.With("cron", name)),
|
||||
schedule.WithConfigReloadInterval(intervalReload, func(ctx context.Context) (time.Duration, error) {
|
||||
appConfig, err := ds.AppConfig(ctx)
|
||||
if err != nil {
|
||||
@@ -556,20 +556,20 @@ func newAutomationsSchedule(
|
||||
"host_status_webhook",
|
||||
func(ctx context.Context) error {
|
||||
return webhooks.TriggerHostStatusWebhook(
|
||||
ctx, ds, kitlog.With(logger, "automation", "host_status"),
|
||||
ctx, ds, logger.With("automation", "host_status"),
|
||||
)
|
||||
},
|
||||
),
|
||||
schedule.WithJob(
|
||||
"fire_outdated_automations",
|
||||
func(ctx context.Context) error {
|
||||
return scheduleFailingPoliciesAutomation(ctx, ds, kitlog.With(logger, "automation", "fire_outdated_automations"), failingPoliciesSet)
|
||||
return scheduleFailingPoliciesAutomation(ctx, ds, logger.With("automation", "fire_outdated_automations"), failingPoliciesSet)
|
||||
},
|
||||
),
|
||||
schedule.WithJob(
|
||||
"failing_policies_automation",
|
||||
func(ctx context.Context) error {
|
||||
return triggerFailingPoliciesAutomation(ctx, ds, kitlog.With(logger, "automation", "failing_policies"), failingPoliciesSet)
|
||||
return triggerFailingPoliciesAutomation(ctx, ds, logger.With("automation", "failing_policies"), failingPoliciesSet)
|
||||
},
|
||||
),
|
||||
)
|
||||
@@ -580,7 +580,7 @@ func newAutomationsSchedule(
|
||||
func scheduleFailingPoliciesAutomation(
|
||||
ctx context.Context,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
failingPoliciesSet fleet.FailingPolicySet,
|
||||
) error {
|
||||
for {
|
||||
@@ -604,7 +604,7 @@ func scheduleFailingPoliciesAutomation(
|
||||
func triggerFailingPoliciesAutomation(
|
||||
ctx context.Context,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
failingPoliciesSet fleet.FailingPolicySet,
|
||||
) error {
|
||||
appConfig, err := ds.AppConfig(ctx)
|
||||
@@ -659,7 +659,7 @@ func newWorkerIntegrationsSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
depStorage *mysql.NanoDEPStorage,
|
||||
commander *apple_mdm.MDMAppleCommander,
|
||||
bootstrapPackageStore fleet.MDMBootstrapPackageStore,
|
||||
@@ -677,7 +677,7 @@ func newWorkerIntegrationsSchedule(
|
||||
maxRunTime = 10 * time.Minute // allow the worker to run for 10 minutes
|
||||
)
|
||||
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
|
||||
// create the worker and register the Jira and Zendesk jobs even if no
|
||||
// integration is enabled, as that config can change live (and if it's not
|
||||
@@ -839,7 +839,7 @@ func newCleanupsAndAggregationSchedule(
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
svc fleet.Service,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
enrollHostLimiter fleet.EnrollHostLimiter,
|
||||
config *config.FleetConfig,
|
||||
commander *apple_mdm.MDMAppleCommander,
|
||||
@@ -856,7 +856,7 @@ func newCleanupsAndAggregationSchedule(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
// Using leader for the lock to be backwards compatilibity with old deployments.
|
||||
schedule.WithAltLockID("leader"),
|
||||
schedule.WithLogger(kitlog.With(logger, "cron", name)),
|
||||
schedule.WithLogger(logger.With("cron", name)),
|
||||
// Run cleanup jobs first.
|
||||
schedule.WithJob(
|
||||
"distributed_query_campaigns",
|
||||
@@ -1096,7 +1096,7 @@ func newFrequentCleanupsSchedule(
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
lq fleet.LiveQueryStore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronFrequentCleanups)
|
||||
@@ -1106,7 +1106,7 @@ func newFrequentCleanupsSchedule(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
// Using leader for the lock to be backwards compatilibity with old deployments.
|
||||
schedule.WithAltLockID("leader_frequent_cleanups"),
|
||||
schedule.WithLogger(kitlog.With(logger, "cron", name)),
|
||||
schedule.WithLogger(logger.With("cron", name)),
|
||||
// Run cleanup jobs first.
|
||||
schedule.WithJob("redis_live_queries", func(ctx context.Context) error {
|
||||
// It's necessary to avoid lingering live queries in case of:
|
||||
@@ -1135,7 +1135,7 @@ func newQueryResultsCleanupSchedule(
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
liveQueryStore fleet.LiveQueryStore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronQueryResultsCleanup)
|
||||
@@ -1143,7 +1143,7 @@ func newQueryResultsCleanupSchedule(
|
||||
)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(kitlog.With(logger, "cron", name)),
|
||||
schedule.WithLogger(logger.With("cron", name)),
|
||||
schedule.WithJob("cleanup_excess_query_results", func(ctx context.Context) error {
|
||||
appConfig, err := ds.AppConfig(ctx)
|
||||
if err != nil {
|
||||
@@ -1169,7 +1169,7 @@ func newQueryResultsCleanupSchedule(
|
||||
|
||||
func verifyDiskEncryptionKeys(
|
||||
ctx context.Context,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
ds fleet.Datastore,
|
||||
) error {
|
||||
appCfg, err := ds.AppConfig(ctx)
|
||||
@@ -1221,14 +1221,14 @@ func verifyDiskEncryptionKeys(
|
||||
return nil
|
||||
}
|
||||
|
||||
func newUsageStatisticsSchedule(ctx context.Context, instanceID string, ds fleet.Datastore, config config.FleetConfig, logger kitlog.Logger) (*schedule.Schedule, error) {
|
||||
func newUsageStatisticsSchedule(ctx context.Context, instanceID string, ds fleet.Datastore, config config.FleetConfig, logger *logging.Logger) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronUsageStatistics)
|
||||
defaultInterval = 1 * time.Hour
|
||||
)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(kitlog.With(logger, "cron", name)),
|
||||
schedule.WithLogger(logger.With("cron", name)),
|
||||
schedule.WithJob(
|
||||
"try_send_statistics",
|
||||
func(ctx context.Context) error {
|
||||
@@ -1281,10 +1281,10 @@ func newAppleMDMDEPProfileAssigner(
|
||||
periodicity time.Duration,
|
||||
ds fleet.Datastore,
|
||||
depStorage *mysql.NanoDEPStorage,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const name = string(fleet.CronAppleMDMDEPProfileAssigner)
|
||||
logger = kitlog.With(logger, "cron", name, "component", "nanodep-syncer")
|
||||
logger = logger.With("cron", name, "component", "nanodep-syncer")
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, periodicity, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1297,7 +1297,7 @@ func newAppleMDMDEPProfileAssigner(
|
||||
func appleMDMDEPSyncerJob(
|
||||
ds fleet.Datastore,
|
||||
depStorage *mysql.NanoDEPStorage,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) func(context.Context) error {
|
||||
var fleetSyncer *apple_mdm.DEPService
|
||||
return func(ctx context.Context) error {
|
||||
@@ -1343,7 +1343,7 @@ func newAppleMDMProfileManagerSchedule(
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
commander *apple_mdm.MDMAppleCommander,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronMDMAppleProfileManager)
|
||||
@@ -1353,7 +1353,7 @@ func newAppleMDMProfileManagerSchedule(
|
||||
defaultInterval = 30 * time.Second
|
||||
)
|
||||
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1372,7 +1372,7 @@ func newWindowsMDMProfileManagerSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronMDMWindowsProfileManager)
|
||||
@@ -1382,7 +1382,7 @@ func newWindowsMDMProfileManagerSchedule(
|
||||
defaultInterval = 30 * time.Second
|
||||
)
|
||||
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1398,7 +1398,7 @@ func newAndroidMDMProfileManagerSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
licenseKey string,
|
||||
androidAgentConfig config.AndroidAgentConfig,
|
||||
) (*schedule.Schedule, error) {
|
||||
@@ -1407,7 +1407,7 @@ func newAndroidMDMProfileManagerSchedule(
|
||||
defaultInterval = 30 * time.Second
|
||||
)
|
||||
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1424,12 +1424,12 @@ func newMDMAppleServiceDiscoverySchedule(
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
depStorage *mysql.NanoDEPStorage,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
urlPrefix string,
|
||||
) (*schedule.Schedule, error) {
|
||||
const name = "mdm_service_discovery"
|
||||
interval := 1 * time.Hour
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, interval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1445,7 +1445,7 @@ func newMDMAPNsPusher(
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
commander *apple_mdm.MDMAppleCommander,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const name = string(fleet.CronAppleMDMAPNsPusher)
|
||||
|
||||
@@ -1459,7 +1459,7 @@ func newMDMAPNsPusher(
|
||||
}
|
||||
}
|
||||
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, interval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1480,7 +1480,7 @@ func newMDMAPNsPusher(
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func cleanupCronStatsOnShutdown(ctx context.Context, ds fleet.Datastore, logger kitlog.Logger, instanceID string) {
|
||||
func cleanupCronStatsOnShutdown(ctx context.Context, ds fleet.Datastore, logger *logging.Logger, instanceID string) {
|
||||
if err := ds.UpdateAllCronStatsForInstance(ctx, instanceID, fleet.CronStatsStatusPending, fleet.CronStatsStatusCanceled); err != nil {
|
||||
logger.Log("err", "cancel pending cron stats for instance", "details", err)
|
||||
}
|
||||
@@ -1491,14 +1491,14 @@ func newActivitiesStreamingSchedule(
|
||||
instanceID string,
|
||||
activitySvc activity_api.Service,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
auditLogger activity_api.JSONLogger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronActivitiesStreaming)
|
||||
interval = 5 * time.Minute
|
||||
)
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, interval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1518,13 +1518,13 @@ func newHostVitalsLabelMembershipSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronHostVitalsLabelMembership)
|
||||
interval = 5 * time.Minute
|
||||
)
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, interval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1569,13 +1569,13 @@ func newBatchActivityCompletionCheckerSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronBatchActivityCompletionChecker)
|
||||
interval = 5 * time.Minute
|
||||
)
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, interval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1600,7 +1600,7 @@ func cronBatchActivityCompletionChecker(
|
||||
return nil
|
||||
}
|
||||
|
||||
func stringSliceToUintSlice(s []string, logger kitlog.Logger) []uint {
|
||||
func stringSliceToUintSlice(s []string, logger *logging.Logger) []uint {
|
||||
result := make([]uint, 0, len(s))
|
||||
for _, v := range s {
|
||||
i, err := strconv.ParseUint(v, 10, 64)
|
||||
@@ -1626,11 +1626,11 @@ func newIPhoneIPadRefetcher(
|
||||
periodicity time.Duration,
|
||||
ds fleet.Datastore,
|
||||
commander *apple_mdm.MDMAppleCommander,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
newActivityFn apple_mdm.NewActivityFunc,
|
||||
) (*schedule.Schedule, error) {
|
||||
const name = string(fleet.CronAppleMDMIPhoneIPadRefetcher)
|
||||
logger = kitlog.With(logger, "cron", name, "component", "iphone-ipad-refetcher")
|
||||
logger = logger.With("cron", name, "component", "iphone-ipad-refetcher")
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, periodicity, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1649,13 +1649,13 @@ func cronUninstallSoftwareMigration(
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
softwareInstallStore fleet.SoftwareInstallerStore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronUninstallSoftwareMigration)
|
||||
defaultInterval = 24 * time.Hour
|
||||
)
|
||||
logger = kitlog.With(logger, "cron", name, "component", name)
|
||||
logger = logger.With("cron", name, "component", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1674,14 +1674,14 @@ func cronUpgradeCodeSoftwareMigration(
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
softwareInstallStore fleet.SoftwareInstallerStore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronUpgradeCodeSoftwareMigration)
|
||||
defaultInterval = 24 * time.Hour
|
||||
priorJobDiff = -(defaultInterval - 30*time.Second)
|
||||
)
|
||||
logger = kitlog.With(logger, "cron", name, "component", name)
|
||||
logger = logger.With("cron", name, "component", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1699,7 +1699,7 @@ func newMaintainedAppSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronMaintainedApps)
|
||||
@@ -1707,7 +1707,7 @@ func newMaintainedAppSchedule(
|
||||
priorJobDiff = -(defaultInterval - 30*time.Second)
|
||||
)
|
||||
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1725,7 +1725,7 @@ func newRefreshVPPAppVersionsSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
vppAppsConfig apple_apps.Config,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
@@ -1733,7 +1733,7 @@ func newRefreshVPPAppVersionsSchedule(
|
||||
defaultInterval = 1 * time.Hour
|
||||
)
|
||||
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1754,10 +1754,10 @@ func newIPhoneIPadReviver(
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
commander *apple_mdm.MDMAppleCommander,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const name = string(fleet.CronAppleMDMIPhoneIPadReviver)
|
||||
logger = kitlog.With(logger, "cron", name, "component", "iphone-ipad-reviver")
|
||||
logger = logger.With("cron", name, "component", "iphone-ipad-reviver")
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, 1*time.Hour, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1773,7 +1773,7 @@ func newUpcomingActivitiesSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronUpcomingActivitiesMaintenance)
|
||||
@@ -1781,7 +1781,7 @@ func newUpcomingActivitiesSchedule(
|
||||
)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(kitlog.With(logger, "cron", name)),
|
||||
schedule.WithLogger(logger.With("cron", name)),
|
||||
schedule.WithJob("unblock_hosts_upcoming_activity_queue", func(ctx context.Context) error {
|
||||
const maxUnblockHosts = 500
|
||||
_, err := ds.UnblockHostsUpcomingActivityQueue(ctx, maxUnblockHosts)
|
||||
@@ -1796,14 +1796,14 @@ func newBatchActivitiesSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
name = string(fleet.CronScheduledBatchActivities)
|
||||
defaultInterval = 2 * time.Minute
|
||||
)
|
||||
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
|
||||
w := worker.NewWorker(ds, logger)
|
||||
|
||||
@@ -1835,7 +1835,7 @@ func newAndroidMDMDeviceReconcilerSchedule(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
licenseKey string,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
@@ -1843,7 +1843,7 @@ func newAndroidMDMDeviceReconcilerSchedule(
|
||||
defaultInterval = 1 * time.Hour
|
||||
)
|
||||
|
||||
logger = kitlog.With(logger, "cron", name)
|
||||
logger = logger.With("cron", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1859,7 +1859,7 @@ func cronEnableAndroidAppReportsOnDefaultPolicy(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
androidSvc android.Service,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
@@ -1867,7 +1867,7 @@ func cronEnableAndroidAppReportsOnDefaultPolicy(
|
||||
defaultInterval = 24 * time.Hour
|
||||
priorJobDiff = -(defaultInterval - 45*time.Second)
|
||||
)
|
||||
logger = kitlog.With(logger, "cron", name, "component", name)
|
||||
logger = logger.With("cron", name, "component", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
@@ -1885,7 +1885,7 @@ func cronMigrateToPerHostPolicy(
|
||||
ctx context.Context,
|
||||
instanceID string,
|
||||
ds fleet.Datastore,
|
||||
logger kitlog.Logger,
|
||||
logger *logging.Logger,
|
||||
androidSvc android.Service,
|
||||
) (*schedule.Schedule, error) {
|
||||
const (
|
||||
@@ -1893,7 +1893,7 @@ func cronMigrateToPerHostPolicy(
|
||||
defaultInterval = 24 * time.Hour
|
||||
priorJobDiff = -(defaultInterval - 30*time.Second)
|
||||
)
|
||||
logger = kitlog.With(logger, "cron", name, "component", name)
|
||||
logger = logger.With("cron", name, "component", name)
|
||||
s := schedule.New(
|
||||
ctx, name, instanceID, defaultInterval, ds, ds,
|
||||
schedule.WithLogger(logger),
|
||||
|
||||
@@ -18,9 +18,8 @@ import (
|
||||
"github.com/fleetdm/fleet/v4/server/mdm/nanodep/godep"
|
||||
"github.com/fleetdm/fleet/v4/server/mock"
|
||||
mdmmock "github.com/fleetdm/fleet/v4/server/mock/mdm"
|
||||
"github.com/fleetdm/fleet/v4/server/platform/logging"
|
||||
"github.com/fleetdm/fleet/v4/server/test"
|
||||
"github.com/go-kit/log"
|
||||
kitlog "github.com/go-kit/log"
|
||||
)
|
||||
|
||||
func TestNewAppleMDMProfileManagerWithoutConfig(t *testing.T) {
|
||||
@@ -28,7 +27,7 @@ func TestNewAppleMDMProfileManagerWithoutConfig(t *testing.T) {
|
||||
mdmStorage := &mdmmock.MDMAppleStore{}
|
||||
ds := new(mock.Store)
|
||||
cmdr := apple_mdm.NewMDMAppleCommander(mdmStorage, nil)
|
||||
logger := kitlog.NewNopLogger()
|
||||
logger := logging.NewNopLogger()
|
||||
|
||||
sch, err := newAppleMDMProfileManagerSchedule(ctx, "foo", ds, cmdr, logger)
|
||||
require.NotNil(t, sch)
|
||||
@@ -38,7 +37,7 @@ func TestNewAppleMDMProfileManagerWithoutConfig(t *testing.T) {
|
||||
func TestNewWindowsMDMProfileManagerWithoutConfig(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ds := new(mock.Store)
|
||||
logger := kitlog.NewNopLogger()
|
||||
logger := logging.NewNopLogger()
|
||||
|
||||
sch, err := newWindowsMDMProfileManagerSchedule(ctx, "foo", ds, logger)
|
||||
require.NotNil(t, sch)
|
||||
@@ -89,7 +88,7 @@ func TestMigrateABMTokenDuringDEPCronJob(t *testing.T) {
|
||||
err = depStorage.StoreConfig(ctx, apple_mdm.UnsavedABMTokenOrgName, &nanodep_client.Config{BaseURL: srv.URL})
|
||||
require.NoError(t, err)
|
||||
|
||||
logger := log.NewNopLogger()
|
||||
logger := logging.NewNopLogger()
|
||||
syncFn := appleMDMDEPSyncerJob(ds, depStorage, logger)
|
||||
err = syncFn(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
+5
-4
@@ -11,7 +11,6 @@ import (
|
||||
"github.com/fleetdm/fleet/v4/server/config"
|
||||
"github.com/fleetdm/fleet/v4/server/platform/logging"
|
||||
"github.com/fleetdm/fleet/v4/server/shellquote"
|
||||
kitlog "github.com/go-kit/log"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/spf13/cobra"
|
||||
otelsdklog "go.opentelemetry.io/otel/sdk/log"
|
||||
@@ -133,8 +132,10 @@ func applyDevFlags(cfg *config.FleetConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
// initLogger creates a kitlog.Logger backed by slog.
|
||||
func initLogger(cfg config.FleetConfig, loggerProvider *otelsdklog.LoggerProvider) kitlog.Logger {
|
||||
// initLogger creates a *Logger backed by slog.
|
||||
// Returning the concrete type allows callers to access the underlying
|
||||
// slog.Logger via SlogLogger() when needed for migrated packages.
|
||||
func initLogger(cfg config.FleetConfig, loggerProvider *otelsdklog.LoggerProvider) *logging.Logger {
|
||||
slogLogger := logging.NewSlogLogger(logging.Options{
|
||||
JSON: cfg.Logging.JSON,
|
||||
Debug: cfg.Logging.Debug,
|
||||
@@ -142,5 +143,5 @@ func initLogger(cfg config.FleetConfig, loggerProvider *otelsdklog.LoggerProvide
|
||||
OtelLogsEnabled: cfg.Logging.OtelLogsEnabled,
|
||||
LoggerProvider: loggerProvider,
|
||||
})
|
||||
return logging.NewKitlogAdapter(slogLogger)
|
||||
return logging.NewLogger(slogLogger)
|
||||
}
|
||||
|
||||
+8
-8
@@ -303,7 +303,7 @@ the way that the Fleet server works.
|
||||
// NOTE this will disable OTEL/APM interceptor
|
||||
if dev_mode.Env("FLEET_DEV_ENABLE_SQL_INTERCEPTOR") != "" {
|
||||
opts = append(opts, mysql.WithInterceptor(&devSQLInterceptor{
|
||||
logger: kitlog.With(logger, "component", "sql-interceptor"),
|
||||
logger: logger.With("component", "sql-interceptor"),
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ the way that the Fleet server works.
|
||||
ds = redisWrapperDS
|
||||
|
||||
resultStore := pubsub.NewRedisQueryResults(redisPool, config.Redis.DuplicateResults,
|
||||
log.With(logger, "component", "query-results"),
|
||||
logger.With("component", "query-results"),
|
||||
)
|
||||
liveQueryStore := live_query.NewRedisLiveQuery(redisPool, logger, liveQueryMemCacheDuration)
|
||||
ssoSessionStore := sso.NewSessionStore(redisPool)
|
||||
@@ -585,7 +585,7 @@ the way that the Fleet server works.
|
||||
}
|
||||
|
||||
var mdmPushService push.Pusher
|
||||
nanoMDMLogger := service.NewNanoMDMLogger(kitlog.With(logger, "component", "apple-mdm-push"))
|
||||
nanoMDMLogger := service.NewNanoMDMLogger(logger.With("component", "apple-mdm-push"))
|
||||
pushProviderFactory := buford.NewPushProviderFactory(buford.WithNewClient(func(cert *tls.Certificate) (*http.Client, error) {
|
||||
return fleethttp.NewClient(fleethttp.WithTLSClientConfig(&tls.Config{
|
||||
Certificates: []tls.Certificate{*cert},
|
||||
@@ -1292,7 +1292,7 @@ the way that the Fleet server works.
|
||||
level.Info(logger).Log("msg", fmt.Sprintf("started cron schedules: %s", strings.Join(cronSchedules.ScheduleNames(), ", ")))
|
||||
|
||||
// StartCollectors starts a goroutine per collector, using ctx to cancel.
|
||||
task.StartCollectors(ctx, kitlog.With(logger, "cron", "async_task"))
|
||||
task.StartCollectors(ctx, logger.With("cron", "async_task"))
|
||||
|
||||
// Flush seen hosts every second
|
||||
hostsAsyncCfg := config.Osquery.AsyncConfigForTask(configpkg.AsyncTaskHostLastSeen)
|
||||
@@ -1325,7 +1325,7 @@ the way that the Fleet server works.
|
||||
|
||||
svc = service.NewMetricsService(svc, requestCount, requestLatency)
|
||||
|
||||
httpLogger := kitlog.With(logger, "component", "http")
|
||||
httpLogger := logger.With("component", "http")
|
||||
|
||||
limiterStore := &redis.ThrottledStore{
|
||||
Pool: redisPool,
|
||||
@@ -1334,7 +1334,7 @@ the way that the Fleet server works.
|
||||
|
||||
var httpSigVerifier func(http.Handler) http.Handler
|
||||
if license.IsPremium() {
|
||||
httpSigVerifier, err = httpsig.Middleware(ds, config.Auth.RequireHTTPMessageSignature, kitlog.With(logger, "component", "http-sig-verifier"))
|
||||
httpSigVerifier, err = httpsig.Middleware(ds, config.Auth.RequireHTTPMessageSignature, logger.With("component", "http-sig-verifier"))
|
||||
if err != nil {
|
||||
initFatal(err, "initializing HTTP signature verifier")
|
||||
}
|
||||
@@ -1482,7 +1482,7 @@ the way that the Fleet server works.
|
||||
}
|
||||
// Host identify and conditional access SCEP feature only works if a private key has been set up
|
||||
if len(config.Server.PrivateKey) > 0 {
|
||||
hostIdentitySCEPDepot, err := mds.NewHostIdentitySCEPDepot(kitlog.With(logger, "component", "host-id-scep-depot"), &config)
|
||||
hostIdentitySCEPDepot, err := mds.NewHostIdentitySCEPDepot(logger.With("component", "host-id-scep-depot"), &config)
|
||||
if err != nil {
|
||||
initFatal(err, "setup host identity SCEP depot")
|
||||
}
|
||||
@@ -1491,7 +1491,7 @@ the way that the Fleet server works.
|
||||
}
|
||||
|
||||
// Conditional Access SCEP
|
||||
condAccessSCEPDepot, err := mds.NewConditionalAccessSCEPDepot(kitlog.With(logger, "component", "conditional-access-scep-depot"), &config)
|
||||
condAccessSCEPDepot, err := mds.NewConditionalAccessSCEPDepot(logger.With("component", "conditional-access-scep-depot"), &config)
|
||||
if err != nil {
|
||||
initFatal(err, "setup conditional access SCEP depot")
|
||||
}
|
||||
|
||||
+10
-15
@@ -24,12 +24,10 @@ import (
|
||||
apple_mdm "github.com/fleetdm/fleet/v4/server/mdm/apple"
|
||||
"github.com/fleetdm/fleet/v4/server/mdm/nanodep/tokenpki"
|
||||
"github.com/fleetdm/fleet/v4/server/mock"
|
||||
"github.com/fleetdm/fleet/v4/server/platform/logging"
|
||||
"github.com/fleetdm/fleet/v4/server/ptr"
|
||||
"github.com/fleetdm/fleet/v4/server/service"
|
||||
"github.com/fleetdm/fleet/v4/server/service/schedule"
|
||||
"github.com/go-kit/log"
|
||||
kitlog "github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/smallstep/pkcs7"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -296,7 +294,7 @@ func TestAutomationsSchedule(t *testing.T) {
|
||||
defer cancelFunc()
|
||||
|
||||
failingPoliciesSet := service.NewMemFailingPolicySet()
|
||||
s, err := newAutomationsSchedule(ctx, "test_instance", ds, kitlog.NewNopLogger(), 5*time.Minute, failingPoliciesSet)
|
||||
s, err := newAutomationsSchedule(ctx, "test_instance", ds, logging.NewNopLogger(), 5*time.Minute, failingPoliciesSet)
|
||||
require.NoError(t, err)
|
||||
s.Start()
|
||||
|
||||
@@ -355,7 +353,7 @@ func TestCronVulnerabilitiesCreatesDatabasesPath(t *testing.T) {
|
||||
// Use schedule to test that the schedule does indeed call cronVulnerabilities.
|
||||
ctx = license.NewContext(ctx, &fleet.LicenseInfo{Tier: fleet.TierPremium})
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
lg := kitlog.NewJSONLogger(os.Stdout)
|
||||
lg := logging.NewNopLogger()
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
@@ -416,8 +414,7 @@ func (f *softwareIterator) Close() error { return nil }
|
||||
func TestScanVulnerabilities(t *testing.T) {
|
||||
nettest.Run(t)
|
||||
|
||||
logger := kitlog.NewNopLogger()
|
||||
logger = level.NewFilter(logger, level.AllowDebug())
|
||||
logger := logging.NewNopLogger()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -600,8 +597,7 @@ func TestScanVulnerabilities(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateVulnHostCounts(t *testing.T) {
|
||||
logger := kitlog.NewNopLogger()
|
||||
logger = level.NewFilter(logger, level.AllowDebug())
|
||||
logger := logging.NewNopLogger()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -645,8 +641,7 @@ func TestUpdateVulnHostCounts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestScanVulnerabilitiesMkdirFailsIfVulnPathIsFile(t *testing.T) {
|
||||
logger := kitlog.NewNopLogger()
|
||||
logger = level.NewFilter(logger, level.AllowDebug())
|
||||
logger := logging.NewNopLogger()
|
||||
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
defer cancelFunc()
|
||||
@@ -722,7 +717,7 @@ func TestCronVulnerabilitiesSkipMkdirIfDisabled(t *testing.T) {
|
||||
// Use schedule to test that the schedule does indeed call cronVulnerabilities.
|
||||
ctx = license.NewContext(ctx, &fleet.LicenseInfo{Tier: fleet.TierPremium})
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
s, err := newVulnerabilitiesSchedule(ctx, "test_instance", ds, kitlog.NewNopLogger(), &config)
|
||||
s, err := newVulnerabilitiesSchedule(ctx, "test_instance", ds, logging.NewNopLogger(), &config)
|
||||
require.NoError(t, err)
|
||||
s.Start()
|
||||
t.Cleanup(func() {
|
||||
@@ -806,7 +801,7 @@ func TestAutomationsScheduleLockDuration(t *testing.T) {
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
defer cancelFunc()
|
||||
|
||||
s, err := newAutomationsSchedule(ctx, "test_instance", ds, kitlog.NewNopLogger(), 1*time.Second, service.NewMemFailingPolicySet())
|
||||
s, err := newAutomationsSchedule(ctx, "test_instance", ds, logging.NewNopLogger(), 1*time.Second, service.NewMemFailingPolicySet())
|
||||
require.NoError(t, err)
|
||||
s.Start()
|
||||
|
||||
@@ -872,7 +867,7 @@ func TestAutomationsScheduleIntervalChange(t *testing.T) {
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
defer cancelFunc()
|
||||
|
||||
s, err := newAutomationsSchedule(ctx, "test_instance", ds, kitlog.NewNopLogger(), 200*time.Millisecond, service.NewMemFailingPolicySet())
|
||||
s, err := newAutomationsSchedule(ctx, "test_instance", ds, logging.NewNopLogger(), 200*time.Millisecond, service.NewMemFailingPolicySet())
|
||||
require.NoError(t, err)
|
||||
s.Start()
|
||||
|
||||
@@ -1019,7 +1014,7 @@ func TestDebugMux(t *testing.T) {
|
||||
func TestVerifyDiskEncryptionKeysJob(t *testing.T) {
|
||||
ds := new(mock.Store)
|
||||
ctx := context.Background()
|
||||
logger := log.NewNopLogger()
|
||||
logger := logging.NewNopLogger()
|
||||
|
||||
testCert, testKey, err := apple_mdm.NewSCEPCACertKey()
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/fleetdm/fleet/v4/server/config"
|
||||
"github.com/fleetdm/fleet/v4/server/datastore/mysql"
|
||||
"github.com/fleetdm/fleet/v4/server/fleet"
|
||||
kitlog "github.com/go-kit/log"
|
||||
"github.com/fleetdm/fleet/v4/server/platform/logging"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -40,8 +40,7 @@ by an exit code of zero.`,
|
||||
applyDevFlags(&cfg)
|
||||
}
|
||||
|
||||
logger := initLogger(cfg, nil)
|
||||
logger = kitlog.With(logger, fleet.CronVulnerabilities)
|
||||
logger := initLogger(cfg, nil).With("cron", fleet.CronVulnerabilities)
|
||||
|
||||
licenseInfo, err := initLicense(&cfg, devLicense, devExpiredLicense)
|
||||
if err != nil {
|
||||
@@ -136,7 +135,7 @@ by an exit code of zero.`,
|
||||
return vulnProcessingCmd
|
||||
}
|
||||
|
||||
func configureVulnPath(vulnConfig config.VulnerabilitiesConfig, appConfig *fleet.AppConfig, logger kitlog.Logger) (vulnPath string) {
|
||||
func configureVulnPath(vulnConfig config.VulnerabilitiesConfig, appConfig *fleet.AppConfig, logger *logging.Logger) (vulnPath string) {
|
||||
switch {
|
||||
case vulnConfig.DatabasesPath != "" && appConfig != nil && appConfig.VulnerabilitySettings.DatabasesPath != "":
|
||||
vulnPath = vulnConfig.DatabasesPath
|
||||
@@ -159,7 +158,7 @@ type NamedVulnFunc struct {
|
||||
VulnFunc func(ctx context.Context) error
|
||||
}
|
||||
|
||||
func getVulnFuncs(ds fleet.Datastore, logger kitlog.Logger, config *config.VulnerabilitiesConfig) []NamedVulnFunc {
|
||||
func getVulnFuncs(ds fleet.Datastore, logger *logging.Logger, config *config.VulnerabilitiesConfig) []NamedVulnFunc {
|
||||
vulnFuncs := []NamedVulnFunc{
|
||||
{
|
||||
Name: "cron_vulnerabilities",
|
||||
|
||||
@@ -10,10 +10,9 @@ import (
|
||||
"github.com/fleetdm/fleet/v4/cmd/fleetctl/fleetctl/testing_utils"
|
||||
"github.com/fleetdm/fleet/v4/server/fleet"
|
||||
"github.com/fleetdm/fleet/v4/server/live_query/live_query_mock"
|
||||
"github.com/fleetdm/fleet/v4/server/platform/logging"
|
||||
"github.com/fleetdm/fleet/v4/server/pubsub"
|
||||
"github.com/fleetdm/fleet/v4/server/service"
|
||||
kitlog "github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -22,8 +21,7 @@ func TestSavedLiveQuery(t *testing.T) {
|
||||
rs := pubsub.NewInmemQueryResults()
|
||||
lq := live_query_mock.New(t)
|
||||
|
||||
logger := kitlog.NewJSONLogger(os.Stdout)
|
||||
logger = level.NewFilter(logger, level.AllowDebug())
|
||||
logger := logging.NewJSONLogger(os.Stdout)
|
||||
|
||||
_, ds := testing_utils.RunServerWithMockedDS(t, &service.TestServerOpts{
|
||||
Rs: rs,
|
||||
@@ -196,8 +194,7 @@ func TestAdHocLiveQuery(t *testing.T) {
|
||||
rs := pubsub.NewInmemQueryResults()
|
||||
lq := live_query_mock.New(t)
|
||||
|
||||
logger := kitlog.NewJSONLogger(os.Stdout)
|
||||
logger = level.NewFilter(logger, level.AllowDebug())
|
||||
logger := logging.NewJSONLogger(os.Stdout)
|
||||
|
||||
_, ds := testing_utils.RunServerWithMockedDS(
|
||||
t, &service.TestServerOpts{
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
|
||||
"github.com/fleetdm/fleet/v4/cmd/fleetctl/fleetctl/testing_utils"
|
||||
"github.com/fleetdm/fleet/v4/server/fleet"
|
||||
"github.com/fleetdm/fleet/v4/server/platform/logging"
|
||||
"github.com/fleetdm/fleet/v4/server/service"
|
||||
"github.com/fleetdm/fleet/v4/server/service/schedule"
|
||||
kitlog "github.com/go-kit/log"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -54,7 +54,7 @@ func TestTrigger(t *testing.T) {
|
||||
os.Stdout = w
|
||||
|
||||
_, _ = testing_utils.RunServerWithMockedDS(t, &service.TestServerOpts{
|
||||
Logger: kitlog.NewNopLogger(),
|
||||
Logger: logging.NewNopLogger(),
|
||||
StartCronSchedules: []service.TestNewScheduleFunc{
|
||||
func(ctx context.Context, ds fleet.Datastore) fleet.NewCronScheduleFunc {
|
||||
return func() (fleet.CronSchedule, error) {
|
||||
|
||||
Reference in New Issue
Block a user