-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update system/socket dataset to support config reloading #21693
Conversation
@@ -51,7 +51,7 @@ const ( | |||
) | |||
|
|||
func init() { | |||
if err := Registry.AddGuess(&guessStructCreds{}); err != nil { | |||
if err := Registry.AddGuess(func() Guesser { return &guessStructCreds{} }); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the changes to guesses are required because, turns out, every guess instance could only run once, as some of them keep internal state (counters, etc.). Replacing the registration with a factory method ensures that when config is reloaded a fresh set of guesses is run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update #21011 at some point to reflect this and probably get rid of the global registry for Guesses.
51d686e
to
ac45283
Compare
Hi! We're labeling this issue as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine to me, but quick question about the execution context of the metricset initialization code.
3cab3c3
to
692792f
Compare
* Update system/socket dataset to support config reloading * Thread-safe singleton (cherry picked from commit 04b064e)
* Update system/socket dataset to support config reloading * Thread-safe singleton (cherry picked from commit 04b064e)
What does this PR do?
This updates the
system/socket
dataset so that it behaves correctly when run under config reloader.When a dataset is run from a static module definition in auditbeat.yml:
When the dataset is configured in the context of configuration reloading:
Also, if
reload.enable
istrue
, everytime the configuration file changes:This behavior didn't play well with a dataset with complex initialization (can take up to 20s to start) and that uses global OS resources (kprobes) that need to be released before a new dataset can be instantiated. There's no mechanism for the reloader to wait for a metricset's termination.
This updates the dataset factory method to keep track of an already running instance. Also it checks if the config has changed to prevent initializing two metricsets at startup.
Why is it important?
Currently Auditbeat will fail with a cryptic error when the socket dataset is started using config reloading. See #20851.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added tests that prove my fix is effective or that my feature worksCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
See the linked issue.
Related issues