Skip to content

Commit 6058645

Browse files
[8.18] [Fleet] Fix unexpected logsdb rollover (elastic#232817) (elastic#233479)
# Backport This will backport the following commits from `main` to `8.18`: - [[Fleet] Fix unexpected logsdb rollover (elastic#232817)](elastic#232817) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Nicolas Chaulet","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-08-25T18:30:41Z","message":"[Fleet] Fix unexpected logsdb rollover (elastic#232817)","sha":"fff236bff7a7c6d489130892b4f8374286e4b4fb","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:Fleet","backport:prev-minor","backport:prev-major","v9.2.0","v9.1.3","v8.19.3"],"title":"[Fleet] Fix unexpected logsdb rollover","number":232817,"url":"https://github.com/elastic/kibana/pull/232817","mergeCommit":{"message":"[Fleet] Fix unexpected logsdb rollover (elastic#232817)","sha":"fff236bff7a7c6d489130892b4f8374286e4b4fb"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/232817","number":232817,"mergeCommit":{"message":"[Fleet] Fix unexpected logsdb rollover (elastic#232817)","sha":"fff236bff7a7c6d489130892b4f8374286e4b4fb"}},{"branch":"9.1","label":"v9.1.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/232846","number":232846,"state":"MERGED","mergeCommit":{"sha":"283112e9ff73882944896c4010e9017c05f6afc8","message":"[9.1] [Fleet] Fix unexpected logsdb rollover (elastic#232817) (elastic#232846)\n\n# Backport\n\nThis will backport the following commits from `main` to `9.1`:\n- [[Fleet] Fix unexpected logsdb rollover\n(elastic#232817)](https://github.com/elastic/kibana/pull/232817)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by: Nicolas Chaulet <[email protected]>"}},{"branch":"8.19","label":"v8.19.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/232843","number":232843,"state":"MERGED","mergeCommit":{"sha":"431f59d86ba33a08ca3f2b32998eb0881638ae8c","message":"[8.19] [Fleet] Fix unexpected logsdb rollover (elastic#232817) (elastic#232843)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.19`:\n- [[Fleet] Fix unexpected logsdb rollover\n(elastic#232817)](https://github.com/elastic/kibana/pull/232817)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by: Nicolas Chaulet <[email protected]>"}},{"url":"https://github.com/elastic/kibana/pull/232960","number":232960,"branch":"deploy-fix@1756102496","state":"MERGED","mergeCommit":{"sha":"30732a8c07286b74200022134a529b4d6f9af807","message":"Fix Fleet rollover (elastic#232960)\n\n## Summary\n\nPR containing:\n* https://github.com/elastic/kibana/pull/232830\n* elastic#232817 \n\nThose fixes avoid infinite rollover for project using cloud connectors"}},{"url":"https://github.com/elastic/kibana/pull/233478","number":233478,"branch":"9.0","state":"OPEN"}]}] BACKPORT--> Co-authored-by: Elastic Machine <[email protected]>
1 parent 98457f7 commit 6058645

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

x-pack/platform/plugins/shared/fleet/server/services/epm/elasticsearch/template/template.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,5 +2452,56 @@ describe('EPM template', () => {
24522452
})
24532453
);
24542454
});
2455+
2456+
it('should not rollover when package do not define index mode and defaut source mode is logsdb', async () => {
2457+
const esClient = elasticsearchServiceMock.createElasticsearchClient();
2458+
esClient.indices.getDataStream.mockResponse({
2459+
data_streams: [{ name: 'logs.prefix1-default' }],
2460+
} as any);
2461+
esClient.indices.get.mockResponse({
2462+
'logs.prefix1-default': {
2463+
mappings: {},
2464+
settings: {
2465+
index: {
2466+
mode: 'logsdb',
2467+
mapping: {
2468+
source: {
2469+
mode: 'STORED',
2470+
},
2471+
},
2472+
},
2473+
},
2474+
},
2475+
} as any);
2476+
esClient.indices.simulateTemplate.mockResponse({
2477+
template: {
2478+
settings: { index: {} },
2479+
mappings: {},
2480+
},
2481+
} as any);
2482+
2483+
const logger = loggerMock.create();
2484+
await updateCurrentWriteIndices(esClient, logger, [
2485+
{
2486+
templateName: 'logs.prefix1',
2487+
indexTemplate: {
2488+
index_patterns: ['logs.prefix1-*'],
2489+
template: {
2490+
settings: { index: {} },
2491+
mappings: {},
2492+
},
2493+
} as any,
2494+
},
2495+
]);
2496+
2497+
expect(esClient.transport.request).not.toHaveBeenCalledWith(
2498+
expect.objectContaining({
2499+
path: '/test.prefix1-default/_rollover',
2500+
querystring: {
2501+
lazy: true,
2502+
},
2503+
})
2504+
);
2505+
});
24552506
});
24562507
});

x-pack/platform/plugins/shared/fleet/server/services/epm/elasticsearch/template/template.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,11 +1145,16 @@ const updateExistingDataStream = async ({
11451145
updatedDynamicDimensionMappings.sort(sortMappings)
11461146
);
11471147

1148+
const packageDefinedIndexMode = settings?.index?.mode;
1149+
// @ts-expect-error Property 'source.mode' does not exist on type 'IndicesMappingLimitSettings'
1150+
const packageDefinedSourceMode = settings?.index?.mapping?.source?.mode;
1151+
11481152
// Trigger a rollover if the index mode or source type has changed
11491153
if (
1150-
currentIndexMode !== settings?.index?.mode ||
1151-
// @ts-expect-error Property 'source.mode' does not exist on type 'IndicesMappingLimitSettings'
1152-
currentSourceType !== settings?.index?.mapping?.source?.mode ||
1154+
(packageDefinedIndexMode !== undefined && currentIndexMode !== settings?.index?.mode) ||
1155+
(packageDefinedSourceMode !== undefined &&
1156+
// @ts-expect-error Property 'source.mode' does not exist on type 'IndicesMappingLimitSettings'
1157+
currentSourceType !== settings?.index?.mapping?.source?.mode) ||
11531158
dynamicDimensionMappingsChanged
11541159
) {
11551160
if (options?.skipDataStreamRollover === true) {

0 commit comments

Comments
 (0)