-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Fix agent policy mappings for space awareness #201689
[Fleet] Fix agent policy mappings for space awareness #201689
Conversation
Pinging @elastic/fleet (Team:Fleet) |
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.
Thanks for fixing this
Object.keys(soTypes['fleet-agent-policies'].mappings).sort() | ||
); | ||
}); | ||
it('should have the same mappings for space and non-space aware package policies', () => { |
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.
nice
… src/core/server/integration_tests/ci_checks'
…nchaulet/kibana into fix-agent-policies-space-aware-mappings
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.
Please avoid using index: false
or enabled: false
.
There's more context in this internal RFC https://docs.google.com/document/d/1wCAaIQ68J1EAPH4eOdWe8LPQvwr3AXPQZx0ryHC7bK0/edit?tab=t.0#bookmark=id.trb1dli8hz4n
But we recently learned that not all teams were aware of this. So we've added some docs https://github.com/elastic/kibana/pull/201969/files and will also remove it from the mappings type so that it causes a type failure (fleet uses this quite extensively so we'll need to add ts-expect-error to ignore these).
@rudolf can we update
|
Yeah it should be possible. That error indicates that somehow you don't have |
@rudolf thank it seems to work when I add an empty
|
⏳ Build in-progress, with failures
Failed CI StepsHistory
cc @nchaulet |
… src/core/server/integration_tests/ci_checks'
@elasticmachine merge upstream |
changes: [ | ||
{ | ||
type: 'mappings_addition', | ||
addedMappings: {}, |
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.
addedMappings: {}, | |
addedMappings: { | |
dynamic: false, | |
}, |
You should also specify the change in mappings here. It's unfortunate that we have this duplication of the mappings definitions, but we didn't see a good way around 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.
@rudolf I tried this but I got a type error Type 'boolean' is not assignable to type 'SavedObjectsFieldMapping'
Should we ignore that error?
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.
ah I see, you're right, looks like a limitation in the modelVersions API in that you can't actually specify a change that sets the top-level dynamic option.
changes: [ | ||
{ | ||
type: 'mappings_addition', | ||
addedMappings: {}, |
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.
addedMappings: {}, | |
addedMappings: { | |
dynamic: false, | |
}, |
We have sent previous guidance around strict API validation. But with making the mappings |
Yes the policy API seems safe on that side, we valid every field added to that saved object. |
changes: [ | ||
{ | ||
type: 'mappings_addition', | ||
addedMappings: {}, |
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.
ah I see, you're right, looks like a limitation in the modelVersions API in that you can't actually specify a change that sets the top-level dynamic option.
Starting backport for target branches: 8.16, 8.17, 8.x |
(cherry picked from commit 721b4be)
(cherry picked from commit 721b4be)
(cherry picked from commit 721b4be)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
#202240) # Backport This will backport the following commits from `main` to `8.17`: - [[Fleet] Fix agent policy mappings for space awareness (#201689)](#201689) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nicolas Chaulet","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-28T22:11:10Z","message":"[Fleet] Fix agent policy mappings for space awareness (#201689)","sha":"721b4beb1ae7f12171a34d50ba6068b8c2d7288e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","backport:prev-minor","v8.17.0","v8.16.2"],"title":"[Fleet] Fix agent policy mappings for space awareness","number":201689,"url":"https://github.com/elastic/kibana/pull/201689","mergeCommit":{"message":"[Fleet] Fix agent policy mappings for space awareness (#201689)","sha":"721b4beb1ae7f12171a34d50ba6068b8c2d7288e"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201689","number":201689,"mergeCommit":{"message":"[Fleet] Fix agent policy mappings for space awareness (#201689)","sha":"721b4beb1ae7f12171a34d50ba6068b8c2d7288e"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Nicolas Chaulet <[email protected]>
#202239) # Backport This will backport the following commits from `main` to `8.16`: - [[Fleet] Fix agent policy mappings for space awareness (#201689)](#201689) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nicolas Chaulet","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-28T22:11:10Z","message":"[Fleet] Fix agent policy mappings for space awareness (#201689)","sha":"721b4beb1ae7f12171a34d50ba6068b8c2d7288e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","backport:prev-minor","v8.17.0","v8.16.2"],"title":"[Fleet] Fix agent policy mappings for space awareness","number":201689,"url":"https://github.com/elastic/kibana/pull/201689","mergeCommit":{"message":"[Fleet] Fix agent policy mappings for space awareness (#201689)","sha":"721b4beb1ae7f12171a34d50ba6068b8c2d7288e"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201689","number":201689,"mergeCommit":{"message":"[Fleet] Fix agent policy mappings for space awareness (#201689)","sha":"721b4beb1ae7f12171a34d50ba6068b8c2d7288e"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Nicolas Chaulet <[email protected]>
…#202241) # Backport This will backport the following commits from `main` to `8.x`: - [[Fleet] Fix agent policy mappings for space awareness (#201689)](#201689) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nicolas Chaulet","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-28T22:11:10Z","message":"[Fleet] Fix agent policy mappings for space awareness (#201689)","sha":"721b4beb1ae7f12171a34d50ba6068b8c2d7288e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","backport:prev-minor","v8.17.0","v8.16.2"],"title":"[Fleet] Fix agent policy mappings for space awareness","number":201689,"url":"https://github.com/elastic/kibana/pull/201689","mergeCommit":{"message":"[Fleet] Fix agent policy mappings for space awareness (#201689)","sha":"721b4beb1ae7f12171a34d50ba6068b8c2d7288e"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201689","number":201689,"mergeCommit":{"message":"[Fleet] Fix agent policy mappings for space awareness (#201689)","sha":"721b4beb1ae7f12171a34d50ba6068b8c2d7288e"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Nicolas Chaulet <[email protected]>
Summary
In #193361 we introduced new mappings for the agent policy.
We now have two saved object for agent policies, one space aware, one not, and mappings should be added to both, that PR fix that.
I also added a unit test so we make sure that both mappings stay the same
How to reproduce
Enable space awareness (feature flag + API call) than try to enable http monitoring