From 8fa8eed09f3549658fe7fe1148f5fd1a236d0b4a Mon Sep 17 00:00:00 2001 From: Julia Bardi Date: Wed, 1 May 2024 10:27:36 +0200 Subject: [PATCH] try with sleep --- internal/pkg/monitor/subscription_monitor.go | 5 ++++- internal/pkg/server/agent.go | 4 ++++ internal/pkg/server/fleet.go | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/pkg/monitor/subscription_monitor.go b/internal/pkg/monitor/subscription_monitor.go index b18f071b8..207112811 100644 --- a/internal/pkg/monitor/subscription_monitor.go +++ b/internal/pkg/monitor/subscription_monitor.go @@ -11,6 +11,7 @@ import ( "time" "github.com/elastic/fleet-server/v7/internal/pkg/es" + "github.com/elastic/fleet-server/v7/internal/pkg/sleep" "github.com/elastic/fleet-server/v7/internal/pkg/sqn" "github.com/rs/zerolog" @@ -116,7 +117,9 @@ func (m *monitorT) Unsubscribe(sub Subscription) { // Run starts the Monitor. func (m *monitorT) Run(ctx context.Context) (err error) { g, gctx := errgroup.WithContext(ctx) - + sleep.WithContext(ctx, 500*time.Millisecond) + zerolog.Ctx(ctx).Info(). + Str("ctx", "subscription monitor").Msg("run subscription monitor") g.Go(func() error { return m.sm.Run(gctx) }) diff --git a/internal/pkg/server/agent.go b/internal/pkg/server/agent.go index 0d39a1c92..ed1ca9b1f 100644 --- a/internal/pkg/server/agent.go +++ b/internal/pkg/server/agent.go @@ -86,6 +86,7 @@ func NewAgent(cliCfg *ucfg.Config, reader io.Reader, bi build.Info, reloadables // Run starts a Server instance using config from the configured client. func (a *Agent) Run(ctx context.Context) error { + sleep.WithContext(ctx, 500*time.Millisecond) log := zerolog.Ctx(ctx) a.agent.RegisterDiagnosticHook("fleet-server config", "fleet-server's current configuration", "fleet-server.yml", "application/yml", func() []byte { a.l.RLock() @@ -422,10 +423,12 @@ func (a *Agent) configFromUnits(ctx context.Context) (*config.Config, error) { } if expAPMCFG := expInput.APMConfig; expAPMCFG != nil { + zerolog.Ctx(ctx).Info().Any("expAPMCFG", expAPMCFG).Msg("apm config to instrumentation") instrumentationCfg, err := apmConfigToInstrumentation(expAPMCFG) if err != nil { zerolog.Ctx(ctx).Warn().Err(err).Msg("Unable to parse expected APM config as instrumentation config") } else { + zerolog.Ctx(ctx).Info().Any("instrumentationCfg", instrumentationCfg).Any("cfgData before", cfgData).Msg("instrumentation cfg") obj := map[string]interface{}{ "inputs": []interface{}{map[string]interface{}{ "server": map[string]interface{}{ @@ -437,6 +440,7 @@ func (a *Agent) configFromUnits(ctx context.Context) (*config.Config, error) { if err != nil { zerolog.Ctx(ctx).Warn().Err(err).Msg("Failed to merge APM config into cfgData") } + zerolog.Ctx(ctx).Info().Any("cfgData after", cfgData).Msg("merged new instrumentation config to cfgData") } } diff --git a/internal/pkg/server/fleet.go b/internal/pkg/server/fleet.go index 081b8b1c4..473e0d50f 100644 --- a/internal/pkg/server/fleet.go +++ b/internal/pkg/server/fleet.go @@ -14,6 +14,7 @@ import ( "time" "github.com/elastic/elastic-agent-client/v7/pkg/client" + "github.com/elastic/fleet-server/v7/internal/pkg/sleep" "github.com/elastic/fleet-server/v7/internal/pkg/state" "go.elastic.co/apm/v2" @@ -76,6 +77,7 @@ type runFuncCfg func(context.Context, *config.Config) error // Run runs the fleet server func (f *Fleet) Run(ctx context.Context, initCfg *config.Config) error { + sleep.WithContext(ctx, 500*time.Millisecond) log := zerolog.Ctx(ctx) err := initCfg.LoadServerLimits() if err != nil { @@ -179,7 +181,7 @@ LOOP: stop(srvCancel, srvEg) select { case err := <-ech: - log.Debug().Err(err).Msg("Server stopped intercepted expected context cancel error.") + log.Info().Err(err).Msg("Server stopped intercepted expected context cancel error.") case <-time.After(time.Second * 5): log.Warn().Msg("Server stopped expected context cancel error missing.") } @@ -285,7 +287,7 @@ func safeWait(g *errgroup.Group, to time.Duration) error { func loggedRunFunc(ctx context.Context, tag string, runfn runFunc) func() error { log := zerolog.Ctx(ctx) return func() error { - log.Debug().Msg(tag + " started") + log.Info().Msg(tag + " started") err := runfn(ctx)