-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Fleet] Settings Framework API and UI #179795
[Fleet] Settings Framework API and UI #179795
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
@@ -0,0 +1,81 @@ | |||
/* |
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.
Created that service that return mappings, api schema validation, and full policy values for a given section (right now we only have AGENT_POLICY_ADVANCED_SETTINGS
)
78a4355
to
64d3598
Compare
import type { SavedObjectsFieldMapping } from '@kbn/core-saved-objects-server'; | ||
import type { z } from 'zod'; | ||
|
||
export interface SettingsConfig { |
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 added the saved_object_field
and api_field
definition here
64d3598
to
459ed22
Compare
/ci |
name: string; | ||
mapping: SavedObjectsFieldMapping; | ||
}; | ||
api_field: { |
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.
used an object here so it easily extendable in the future,
/ci |
@@ -156,6 +157,7 @@ export const getSavedObjectTypes = (): { [key: string]: SavedObjectsType } => ({ | |||
is_protected: { type: 'boolean' }, | |||
overrides: { type: 'flattened', index: false }, | |||
keep_monitoring_alive: { type: 'boolean' }, | |||
...getSettingsSavedObjectMappings('AGENT_POLICY_ADVANCED_SETTINGS'), |
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.
Saved objects
*I think we will still have to do some work to add a new model version when adding a new saved object field, I do not see an easy way to programatically generate that. In a first time it probably could be a manual action to add those migration
I see what you mean, without adding model versions, I am getting an error when trying to set the new field
{
"statusCode": 400,
"error": "Bad Request",
"message": "[1:349] mapping set to strict, dynamic introduction of [agent_limits_go_max_procs] within [ingest-agent-policies] is not allowed: strict_dynamic_mapping_exception\n\tRoot causes:\n\t\tstrict_dynamic_mapping_exception: [1:349] mapping set to strict, dynamic introduction of [agent_limits_go_max_procs] within [ingest-agent-policies] is not allowed"
}
Added this modelVersions
locally to get it working:
modelVersions: {
'1': {
changes: [
{
type: 'mappings_addition',
addedMappings: {
...getSettingsSavedObjectMappings('AGENT_POLICY_ADVANCED_SETTINGS'),
},
},
],
},
},
I am wondering if we could add a generic mapping here, since these fields are usually not indexed anyway, something like:
advanced_settings: { type: 'flattened', index: false }
One caveat with this would be that we can't set a field type mapping on specific fields e.g. go_max_procs
to be an integer
. But I think it doesn't matter since the fields are not indexed.
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 made this work locally, to save these settings under a generic advanced_settings
mapping in the SO. The full agent policy hasn't changed.
PUT kbn:/api/fleet/agent_policies/b180cbb0-b276-4f96-97a7-e2acb97c6a36
{
"name": "Agent policy 2",
"namespace": "default",
"advanced_settings": {
"agent_limits_go_max_procs": 6
}
}
This simplifies the settings config that we don't need saved_object_field
.
/ci |
/ci |
/ci |
} | ||
> | ||
<EuiFormRow fullWidth key={fieldKey} error={error} isInvalid={!!error}> | ||
<EuiFieldText |
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.
there is a lot of duplication between number and text type, I wonder if there could be a common component as a wrapper
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.
refactored this component to use a common SettingsFieldWrapper
/ci |
/ci |
… src/core/server/integration_tests/ci_checks'
Pinging @elastic/fleet (Team:Fleet) |
/ci |
name: string; | ||
}; | ||
// form error state is passed up to the form | ||
updateAdvancedSettingsHasErrors?: (hasErrors: boolean) => void; |
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 don't really like this to add a function to the SettingsConfig
, haven't found a better way to pass down this function to the dynamic components.
It is needed to make the submit button disabled if one of the advanced fields are invalid.
EDIT: I found a better solution to put this function in AgentPolicyFormContext
547f9ed
to
6879094
Compare
6935271
to
779acf5
Compare
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
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 for picking up where Nicolas and I left off 🙂
@@ -69,6 +69,10 @@ properties: | |||
type: object | |||
description: Override settings that are defined in the agent policy. Input settings cannot be overridden. The override option should be used only in unusual circumstances and not as a routine procedure. | |||
nullable: true | |||
advanced_settings: |
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.
We decided to go with a generic advanced_settings
in openapi for now. We will look at generating the openapi spec from the settings config later.
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 for the descriptions! 👍
🚀 |
Summary
Follow up on #170539
Related to https://github.com/elastic/ingest-dev/issues/2471 (Phase 1)
Dynamically creating settings fields from configuration.
These settings are saved in the agent policy SO's
advanced_settings
field.In the current pr the agent policy read/create/update works including the UI.
It still has to be extended to support a few more type of settings: e.g. dropdown values, settings consisting of multiple fields.
These settings are added to the full agent policy agents section:
Old description:
Add support for saved object mapping and api field name,
Example API calls and full policy generation
Open questions/Issues
Saved objects
*I think we will still have to do some work to add a new model version when adding a new saved object field, I do not see an easy way to programatically generate that. In a first time it probably could be a manual action to add those migration
API
Open api generation, I think as a first iteration it could be a manual operation to update openAPI spec, but we should be able to programatically generate that with a script in the future