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

[backend] update el core settings when updating indices mappings (#9157) #9179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions opencti-platform/opencti-graphql/src/database/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@
});
}
};
const elCreateCoreSettings = async () => {
const updateCoreSettings = async () => {
await engine.cluster.putComponentTemplate({
name: `${ES_INDEX_PREFIX}-core-settings`,
create: false,
Expand Down Expand Up @@ -1022,13 +1022,15 @@
// Create / update template
const componentTemplateExist = await engine.cluster.existsComponentTemplate({ name: `${ES_INDEX_PREFIX}-core-settings` });
if (!componentTemplateExist) {
await elCreateCoreSettings();
await updateCoreSettings();

Check warning on line 1025 in opencti-platform/opencti-graphql/src/database/engine.js

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/database/engine.js#L1025

Added line #L1025 was not covered by tests
}
return updateIndexTemplate(index, mappingProperties);
};
const sortMappingsKeys = (o) => (Object(o) !== o || Array.isArray(o) ? o
: Object.keys(o).sort().reduce((a, k) => ({ ...a, [k]: sortMappingsKeys(o[k]) }), {}));
export const elUpdateIndicesMappings = async () => {
// Update core settings
await updateCoreSettings();

Check warning on line 1033 in opencti-platform/opencti-graphql/src/database/engine.js

View check run for this annotation

Codecov / codecov/patch

opencti-platform/opencti-graphql/src/database/engine.js#L1032-L1033

Added lines #L1032 - L1033 were not covered by tests
// Reset the templates
const mappingProperties = engineMappingGenerator();
const templates = await elPlatformTemplates();
Expand Down Expand Up @@ -1114,7 +1116,7 @@
return null;
};
export const elCreateIndices = async (indexesToCreate = WRITE_PLATFORM_INDICES) => {
await elCreateCoreSettings();
await updateCoreSettings();
await elCreateLifecyclePolicy();
const createdIndices = [];
const mappingProperties = engineMappingGenerator();
Expand Down