Skip to content

Commit

Permalink
[8.16] [Fleet] Fix agent policy mappings for space awareness (#201689) (
Browse files Browse the repository at this point in the history
#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]>
  • Loading branch information
kibanamachine and nchaulet authored Nov 28, 2024
1 parent 2e1ed36 commit 60efa2c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/kbn-check-mappings-update-cli/current_mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
}
},
"fleet-agent-policies": {
"dynamic": false,
"properties": {
"advanced_settings": {
"index": false,
Expand Down Expand Up @@ -1948,6 +1949,7 @@
"properties": {}
},
"ingest-agent-policies": {
"dynamic": false,
"properties": {
"advanced_settings": {
"index": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"file": "6b65ae5899b60ebe08656fd163ea532e557d3c98",
"file-upload-usage-collection-telemetry": "06e0a8c04f991e744e09d03ab2bd7f86b2088200",
"fileShare": "5be52de1747d249a221b5241af2838264e19aaa1",
"fleet-agent-policies": "f57d3b70e4175a19a18f18ee72a379ceec82e1fc",
"fleet-agent-policies": "908765a33aab066f4ac09446686b2d884aceed00",
"fleet-fleet-server-host": "69be15f6b6f2a2875ad3c7050ddea7a87f505417",
"fleet-message-signing-keys": "93421f43fed2526b59092a4e3c65d64bc2266c0f",
"fleet-package-policies": "2f4d524adb49a5281d3af0b66bb3003ba0ff2e44",
Expand All @@ -120,7 +120,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"infra-custom-dashboards": "1a5994f2e05bb8a1609825ddbf5012f77c5c67f3",
"infrastructure-monitoring-log-view": "5f86709d3c27aed7a8379153b08ee5d3d90d77f5",
"infrastructure-ui-source": "113182d6895764378dfe7fa9fa027244f3a457c4",
"ingest-agent-policies": "5e95e539826a40ad08fd0c1d161da0a4d86ffc6d",
"ingest-agent-policies": "c1818c4119259908875b4c777ae62b11ba0585cd",
"ingest-download-sources": "279a68147e62e4d8858c09ad1cf03bd5551ce58d",
"ingest-outputs": "daafff49255ab700e07491376fe89f04fc998b91",
"ingest-package-policies": "53a94064674835fdb35e5186233bcd7052eabd22",
Expand Down
32 changes: 32 additions & 0 deletions x-pack/plugins/fleet/server/saved_objects/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import _ from 'lodash';

import { getSavedObjectTypes } from '.';

describe('space aware models', () => {
it('should have the same mappings for space and non-space aware agent policies', () => {
const soTypes = getSavedObjectTypes();

const legacyMappings = _.omit(
soTypes['ingest-agent-policies'].mappings,
'properties.monitoring_diagnostics',
'properties.monitoring_http',
'properties.monitoring_pprof_enabled'
);

expect(legacyMappings).toEqual(soTypes['fleet-agent-policies'].mappings);
});
it('should have the same mappings for space and non-space aware package policies', () => {
const soTypes = getSavedObjectTypes();

expect(soTypes['ingest-package-policies'].mappings).toEqual(
soTypes['fleet-package-policies'].mappings
);
});
});
20 changes: 20 additions & 0 deletions x-pack/plugins/fleet/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export const getSavedObjectTypes = (
importableAndExportable: false,
},
mappings: {
dynamic: false,
properties: {
name: { type: 'keyword' },
schema_version: { type: 'version' },
Expand Down Expand Up @@ -304,6 +305,14 @@ export const getSavedObjectTypes = (
},
],
},
'5': {
changes: [
{
type: 'mappings_addition',
addedMappings: {},
},
],
},
},
},
[AGENT_POLICY_SAVED_OBJECT_TYPE]: {
Expand All @@ -315,6 +324,7 @@ export const getSavedObjectTypes = (
importableAndExportable: false,
},
mappings: {
dynamic: false,
properties: {
name: { type: 'keyword' },
schema_version: { type: 'version' },
Expand Down Expand Up @@ -349,6 +359,16 @@ export const getSavedObjectTypes = (
global_data_tags: { type: 'flattened', index: false },
},
},
modelVersions: {
'1': {
changes: [
{
type: 'mappings_addition',
addedMappings: {},
},
],
},
},
},
[OUTPUT_SAVED_OBJECT_TYPE]: {
name: OUTPUT_SAVED_OBJECT_TYPE,
Expand Down

0 comments on commit 60efa2c

Please sign in to comment.