Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersonQ committed Sep 29, 2022
1 parent 856eee3 commit 1f8a006
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/fleet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func initLogger(cfg *config.Config, version, commit string) (*logger.Logger, err
Str("exe", os.Args[0]).
Strs("args", os.Args[1:]).
Msg("Boot fleet-server")
log.Debug().Strs("env", os.Environ()).Msg("environment")
log.Debug().Strs("env", os.Environ()).Msg("environment variables")

return l, err
}
Expand Down Expand Up @@ -832,7 +832,7 @@ func (f *FleetServer) runSubsystems(ctx context.Context, cfg *config.Config, g *
return dl.Migrate(ctx, bulker)
})
if err = loggedMigration(); err != nil {
return fmt.Errorf("failed to run subsystems: %w", err)
return fmt.Errorf("failed to run migrations: %w", err)
}

// Run scheduler for periodic GC/cleanup
Expand Down
9 changes: 6 additions & 3 deletions internal/pkg/dl/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,16 @@ func migrate(ctx context.Context, bulker bulk.Bulk, fn migrationBodyFn) (int, er
for {
name, index, body, err := fn()
if err != nil {
return updatedDocs, fmt.Errorf(": %w", err)
return updatedDocs,
fmt.Errorf("failed to prepare request for migration %s: %w",
name, err)
}

resp, err := applyMigration(ctx, name, index, bulker, body)
if err != nil {
log.Err(err).
Bytes("http.request.body.content", body).
Msgf("migration %s failed: %w", err)
return updatedDocs, fmt.Errorf("failed to apply migration %q: %w",
name, err)
}
Expand Down Expand Up @@ -260,8 +265,6 @@ ctx._source.policy_output_permissions_hash="";

body, err := query.MarshalJSON()
if err != nil {
log.Debug().Str("painlessScript", painless).
Msgf("%s: failed painless script", migrationName)
return migrationName, FleetAgents, nil, fmt.Errorf("could not marshal ES query: %w", err)
}

Expand Down

0 comments on commit 1f8a006

Please sign in to comment.