Skip to content

Commit 1abe97b

Browse files
authored
Make o365audit input cancellable (#21647)
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.
1 parent e4df450 commit 1abe97b

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

x-pack/filebeat/input/o365audit/input.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ import (
2121
"github.com/elastic/beats/v7/libbeat/logp"
2222
"github.com/elastic/beats/v7/x-pack/filebeat/input/o365audit/poll"
2323
"github.com/elastic/go-concert/ctxtool"
24+
"github.com/elastic/go-concert/timed"
2425
)
2526

2627
const (
2728
pluginName = "o365audit"
2829
fieldsPrefix = pluginName
29-
30-
// How long to retry when a fatal error is encountered in the input.
31-
failureRetryInterval = time.Minute * 5
3230
)
3331

3432
type o365input struct {
@@ -126,8 +124,8 @@ func (inp *o365input) Run(
126124
}
127125
publisher.Publish(event, nil)
128126
ctx.Logger.Errorf("Input failed: %v", err)
129-
ctx.Logger.Infof("Restarting in %v", failureRetryInterval)
130-
time.Sleep(failureRetryInterval)
127+
ctx.Logger.Infof("Restarting in %v", inp.config.API.ErrorRetryInterval)
128+
timed.Wait(ctx.Cancelation, inp.config.API.ErrorRetryInterval)
131129
}
132130
}
133131
return nil

0 commit comments

Comments
 (0)