-
Notifications
You must be signed in to change notification settings - Fork 149
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
Fix / clarify capabilities API #2952
Conversation
This pull request does not have a backport label. Could you fix it @faec? 🙏
NOTE: |
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
🌐 Coverage report
|
Since this change fixes a bug, any reason we shouldn't backport it? |
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.
LGTM.
Hmm, it does fix a bug but it's also downstream of the big |
Looks like |
I really love how simple and readable
|
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.
LGTM. Thanks @faec for making the capabilities APIs more explicit and simplifying the tests in the process as well.
Refactor the capabilities manager to address #2951 and associated issues, allowing dramatic simplification of capability logic. There are two types of capability invocation, described in #2951. They are currently called on semi-opaque config trees, but in reality each type has a simple explicit variable dependency: upgrade checks need the
version
andsourceURI
, and input/output checks need the name of the input/output type. This refactor makes that dependency explicit in the API, removing the rest of the config tree and requiring only the specific fields the capability needs.After talking with @cmacknz, I've also included the fix for #2949 and updated the relevant tests.
The high-level changes are:
Apply
function, theCapabilities
interface now defines three calls,AllowInput(inputType string)
,AllowOutput(outputType string)
, andAllowUpgrade(version string, upgradeURI string)
.Coordinator
is now responsible for calling the appropriate API, instead of invokingApply
at every potential call point. In particular,Coordinator
now filters input/output types itself usingAllowInput
andAllowOutput
--Coordinator
already needs to traverse these component structures, and this means that all capabilities code that previously needed to traverse an untypedinterface{}
tree can be removed. This also fixes Input/output capabilities miss input types defined by variables #2950 since the new checks are run on the final input/output names instead of the raw configuration tree.stringMatcher
, and the input vs output distinction is now owned bycapabilitiesManager
which has separate arrays for the two cases.Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesI have added an entry in./changelog/fragments
using the changelog toolI have added an integration test or an E2E testRelated issues