From 1bcbf1d6926e3c7c27b7c8b85a0053d6f5982ed1 Mon Sep 17 00:00:00 2001 From: Adrian Serrano Date: Tue, 13 Oct 2020 17:28:33 +0100 Subject: [PATCH] Make o365audit input cancellable (#21647) (#21701) PR #21258 introduced a restart mechanism for o365input so that it didn't stop working once a fatal error was found. This updates the restart delay to use a cancellation-context-aware method so that the input doesn't block Filebeat termination. (cherry picked from commit 1abe97b20d708d9dd61018163a7d45616b415c59) --- x-pack/filebeat/input/o365audit/input.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/x-pack/filebeat/input/o365audit/input.go b/x-pack/filebeat/input/o365audit/input.go index 1a97768c156..580edb4cb17 100644 --- a/x-pack/filebeat/input/o365audit/input.go +++ b/x-pack/filebeat/input/o365audit/input.go @@ -21,14 +21,12 @@ import ( "github.com/elastic/beats/v7/libbeat/logp" "github.com/elastic/beats/v7/x-pack/filebeat/input/o365audit/poll" "github.com/elastic/go-concert/ctxtool" + "github.com/elastic/go-concert/timed" ) const ( pluginName = "o365audit" fieldsPrefix = pluginName - - // How long to retry when a fatal error is encountered in the input. - failureRetryInterval = time.Minute * 5 ) type o365input struct { @@ -126,8 +124,8 @@ func (inp *o365input) Run( } publisher.Publish(event, nil) ctx.Logger.Errorf("Input failed: %v", err) - ctx.Logger.Infof("Restarting in %v", failureRetryInterval) - time.Sleep(failureRetryInterval) + ctx.Logger.Infof("Restarting in %v", inp.config.API.ErrorRetryInterval) + timed.Wait(ctx.Cancelation, inp.config.API.ErrorRetryInterval) } } return nil