Skip to content
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

[8.x] [Fleet] Fix upgrade with a large number of stream backing indices (#201272) #201801

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1870,9 +1870,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 @@ -1912,6 +1922,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 @@ -61,6 +61,7 @@ export interface CurrentDataStream {
dataStreamName: string;
replicated: boolean;
indexTemplate: IndexTemplate;
currentWriteIndex: string;
}

const DEFAULT_IGNORE_ABOVE = 1024;
Expand Down Expand Up @@ -944,6 +945,7 @@ const getDataStreams = async (
dataStreamName: dataStream.name,
replicated: dataStream.replicated,
indexTemplate,
currentWriteIndex: dataStream.indices?.at(-1)?.index_name,
}));
};

Expand Down Expand Up @@ -979,6 +981,7 @@ const updateAllDataStreams = async (
return updateExistingDataStream({
esClient,
logger,
currentWriteIndex: templateEntry.currentWriteIndex,
dataStreamName: templateEntry.dataStreamName,
options,
});
Expand All @@ -992,11 +995,13 @@ const updateAllDataStreams = async (

const updateExistingDataStream = async ({
dataStreamName,
currentWriteIndex,
esClient,
logger,
options,
}: {
dataStreamName: string;
currentWriteIndex: string;
esClient: ElasticsearchClient;
logger: Logger;
options?: {
Expand All @@ -1005,7 +1010,7 @@ const updateExistingDataStream = async ({
};
}) => {
const existingDs = await esClient.indices.get({
index: dataStreamName,
index: currentWriteIndex,
});

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