From 3e76d59379929b01540bd813f95a7833c943d95d Mon Sep 17 00:00:00 2001 From: Aleksandr Maus Date: Fri, 10 Sep 2021 12:19:11 -0400 Subject: [PATCH] Osquerybeat: Fix 7.15 extension start failure on windows --- x-pack/osquerybeat/beater/osquerybeat.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/osquerybeat/beater/osquerybeat.go b/x-pack/osquerybeat/beater/osquerybeat.go index 6e1406b739fd..5e5923bc909c 100644 --- a/x-pack/osquerybeat/beater/osquerybeat.go +++ b/x-pack/osquerybeat/beater/osquerybeat.go @@ -194,7 +194,7 @@ func (bt *osquerybeat) Run(b *beat.Beat) error { for { select { case <-ctx.Done(): - bt.log.Info("context cancelled, exiting") + bt.log.Info("osquerybeat context cancelled, exiting") return ctx.Err() case inputConfigs := <-inputConfigCh: bt.pub.Configure(inputConfigs) @@ -258,11 +258,6 @@ func (bt *osquerybeat) runOsquery(ctx context.Context, b *beat.Beat, osq *osqd.O bt.handleSnapshotResult(ctx, cli, configPlugin, res) }) - // Run extensions - g.Go(func() error { - return runExtensionServer(ctx, socketPath, configPlugin, loggerPlugin, osqueryTimeout) - }) - // Run main loop g.Go(func() error { // Connect to osqueryd @@ -272,6 +267,11 @@ func (bt *osquerybeat) runOsquery(ctx context.Context, b *beat.Beat, osq *osqd.O } defer cli.Close() + // Run extensions only after succesful connect, otherwise the extension server fails with windows pipes if the pipe was not created by osqueryd yet + g.Go(func() error { + return runExtensionServer(ctx, socketPath, configPlugin, loggerPlugin, osqueryTimeout) + }) + // Register action handler ah := bt.registerActionHandler(b, cli) defer bt.unregisterActionHandler(b, ah) @@ -280,7 +280,7 @@ func (bt *osquerybeat) runOsquery(ctx context.Context, b *beat.Beat, osq *osqd.O for { select { case <-ctx.Done(): - bt.log.Info("context cancelled, exiting") + bt.log.Info("runOsquery context cancelled, exiting") return ctx.Err() case inputConfigs := <-inputCh: err = configPlugin.Set(inputConfigs)