Skip to content

Commit

Permalink
[Fleet] Fix upgrade with a large number of stream backing indices
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Nov 21, 2024
1 parent fa100b4 commit c301289
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1900,9 +1900,19 @@ describe('EPM template', () => {

it('should fill constant keywords from previous mappings', async () => {
const esClient = elasticsearchServiceMock.createElasticsearchClient();

esClient.indices.getDataStream.mockResponse({
data_streams: [{ name: 'test-constant.keyword-default' }],
data_streams: [
{
name: 'test-constant.keyword-default',
indices: [
{ index_name: '.ds-test-constant.keyword-default-0001' },
{ index_name: '.ds-test-constant.keyword-default-0002' },
],
},
],
} as any);

esClient.indices.get.mockResponse({
'test-constant.keyword-default': {
mappings: {
Expand Down Expand Up @@ -1942,6 +1952,9 @@ describe('EPM template', () => {
} as any,
},
]);
expect(esClient.indices.get).toBeCalledWith({
index: '.ds-test-constant.keyword-default-0002',
});
const putMappingsCalls = esClient.indices.putMapping.mock.calls;
expect(putMappingsCalls).toHaveLength(1);
expect(putMappingsCalls[0][0]).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,13 @@ const updateExistingDataStream = async ({
skipDataStreamRollover?: boolean;
};
}) => {
const dataStream = await esClient.indices.getDataStream({
name: dataStreamName,
expand_wildcards: ['open', 'hidden'],
});

const existingDs = await esClient.indices.get({
index: dataStreamName,
index: dataStream?.data_streams?.[0]?.indices?.at(-1)?.index_name ?? dataStreamName,
});

const existingDsConfig = Object.values(existingDs);
Expand Down

0 comments on commit c301289

Please sign in to comment.