From 2b6b8e57892aafb515a8074ef92fb2c4e3e2fad1 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 10 Sep 2021 15:25:14 -0400 Subject: [PATCH] Osquerybeat: Fix 7.15 extension start failure on windows (#27868) (#27872) (cherry picked from commit 537f4036eaee512a38636118143c8b2b4a84fc6c) Co-authored-by: Aleksandr Maus --- 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 6f87c9d89c90..f5ae3b61c5f7 100644 --- a/x-pack/osquerybeat/beater/osquerybeat.go +++ b/x-pack/osquerybeat/beater/osquerybeat.go @@ -197,7 +197,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: // Only set processor if it was not set before @@ -261,11 +261,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 @@ -275,6 +270,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) @@ -283,7 +283,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)