-
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
Cleanup: Stop using the global plugin registry for the Beats manager #34958
Conversation
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
Hmm, not sure what to make of the linter error |
/test |
I still don't know what's going on with the linter but some of the other test failures are real, I'm investigating |
I believe I found the problem -- my code wasn't checking While fixing that I made a few more cleanups (I removed the UUID from the factory interface since nothing used it; I also made the factory invocation internal to the management package, so now clients just call |
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 looks pretty reasonable to me.
This PR is a functional no-op, it merely simplifies some initialization code.
The code being modified handles the creation of the Beats Manager object. When linked with
x-pack
, this object should be created byNewV2AgentManager
, and otherwise it should be an empty placeholder. These are the only possible values, except for some unit tests that replace it with a mocked version.Despite the relatively simple functionality, the current code goes through some heavily abstracted steps:
"libbeat.management"
"libbeat.management"
and look for a plugin that can accept the given configuration. If one is found, use it to create an appropriate factory"libbeat.management"
entries; then add a mocked equivalent to the registry so it is picked up during initialization....all to correctly invoke an initialization function that in live code can only ever have a single globally unique value, known at build-time.
This PR removes that machinery and replaces it with a single global variable protected by a mutex. Updating this variable for
x-pack
or unit tests now involves simply calling the helpermanagement.SetManagerFactory
instead of working with the feature registry to create or scan a list of plugins. The manager is now created withmanagement.NewManager
instead of the indirection of a factory that is immediately invoked by the caller.Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesI have added tests that prove my fix is effective or that my feature worksI have added an entry inCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.