Skip to content

Commit

Permalink
Make o365audit input cancellable (#21647) (#21700)
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 committed Oct 13, 2020
1 parent 62b30d9 commit e2cc738
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 e2cc738

Please sign in to comment.