Skip to content

Commit

Permalink
Make o365audit input cancellable (#21647) (#21702)
Browse files Browse the repository at this point in the history
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 1abe97b)
  • Loading branch information
adriansr authored Oct 13, 2020
1 parent 922cc2d commit eef2ed9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions x-pack/filebeat/input/o365audit/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit eef2ed9

Please sign in to comment.