Skip to content
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

Cherry-pick #21693 to 7.x: Update system/socket dataset to support config reloading #22730

Merged
merged 2 commits into from
Nov 24, 2020

Conversation

adriansr
Copy link
Contributor

@adriansr adriansr commented Nov 24, 2020

Cherry-pick of PR #21693 to 7.x branch. Original message:

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:

  • Factory method New is called.
  • (instance).Run is called.

When the dataset is configured in the context of configuration reloading:

  • Factory method New is called to validate that the config is OK. The returned instance is discarded without its context being closed.
  • Factory method New is called again.
  • (instance).Run is called for the instance returned by the second New.

Also, if reload.enable is true, everytime the configuration file changes:

  • The metricset context is closed.
  • A new instance is created using New.
  • (instance).Run is called.

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

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] 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 works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

How to test this PR locally

See the linked issue.

Related issues

* Update system/socket dataset to support config reloading

* Thread-safe singleton

(cherry picked from commit 04b064e)
@adriansr adriansr requested a review from a team as a code owner November 24, 2020 10:14
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Nov 24, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Nov 24, 2020
@adriansr adriansr requested review from a team and removed request for a team November 24, 2020 10:14
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #22730 opened]

  • Start Time: 2020-11-24T10:14:50.965+0000

  • Duration: 25 min 38 sec

Test stats 🧪

Test Results
Failed 0
Passed 228
Skipped 33
Total 261

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 228
Skipped 33
Total 261

Copy link
Contributor

@leehinman leehinman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adriansr adriansr merged commit a0e2346 into elastic:7.x Nov 24, 2020
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #22730 updated]

  • Start Time: 2020-11-24T18:11:08.304+0000

  • Duration: 22 min 22 sec

Test stats 🧪

Test Results
Failed 0
Passed 228
Skipped 33
Total 261

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 228
Skipped 33
Total 261

@zube zube bot removed the [zube]: Done label Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants