Skip to content

Commit

Permalink
Make o365audit input cancellable (elastic#21647)
Browse files Browse the repository at this point in the history
PR elastic#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 9, 2020
1 parent e8f1cef commit a06f5ec
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 a06f5ec

Please sign in to comment.