Skip to content

Commit

Permalink
try with sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed May 1, 2024
1 parent e9ed1a8 commit 8fa8eed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion internal/pkg/monitor/subscription_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)

Check failure on line 120 in internal/pkg/monitor/subscription_monitor.go

View workflow job for this annotation

GitHub Actions / lint (linux)

Error return value of `sleep.WithContext` is not checked (errcheck)
zerolog.Ctx(ctx).Info().
Str("ctx", "subscription monitor").Msg("run subscription monitor")
g.Go(func() error {
return m.sm.Run(gctx)
})
Expand Down
4 changes: 4 additions & 0 deletions internal/pkg/server/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 89 in internal/pkg/server/agent.go

View workflow job for this annotation

GitHub Actions / lint (linux)

Error return value of `sleep.WithContext` is not checked (errcheck)
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()
Expand Down Expand Up @@ -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{}{
Expand All @@ -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")
}

}
Expand Down
6 changes: 4 additions & 2 deletions internal/pkg/server/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Check failure on line 80 in internal/pkg/server/fleet.go

View workflow job for this annotation

GitHub Actions / lint (linux)

Error return value of `sleep.WithContext` is not checked (errcheck)
log := zerolog.Ctx(ctx)
err := initCfg.LoadServerLimits()
if err != nil {
Expand Down Expand Up @@ -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.")
}
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 8fa8eed

Please sign in to comment.