Skip to content
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 @@ -216,11 +216,10 @@ const installPreBuiltComponentTemplates = async (

const esClientParams = {
name: templateName,
body: content,
...content,
};

return retryTransientEsErrors(
// @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584
() => esClient.cluster.putComponentTemplate(esClientParams, { ignore: [404] }),
{ logger }
);
Expand Down Expand Up @@ -695,10 +694,9 @@ async function installTemplate({
// TODO: Check return values for errors
const esClientParams = {
name: template.templateName,
body: template.indexTemplate,
...template.indexTemplate,
};
await retryTransientEsErrors(
// @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584
() => esClient.indices.putIndexTemplate(esClientParams, { ignore: [404] }),
{ logger }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2037,12 +2037,10 @@ describe('EPM template', () => {
expect(putMappingsCalls).toHaveLength(1);
expect(putMappingsCalls[0][0]).toEqual({
index: 'test-constant.keyword-default',
body: {
properties: {
some_keyword_field: {
type: 'constant_keyword',
value: 'some_value',
},
properties: {
some_keyword_field: {
type: 'constant_keyword',
value: 'some_value',
},
},
write_index_only: true,
Expand Down Expand Up @@ -2087,7 +2085,6 @@ describe('EPM template', () => {
expect(putMappingsCalls).toHaveLength(1);
expect(putMappingsCalls[0][0]).toEqual({
index: 'test-constant.keyword-default',
body: {},
write_index_only: true,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1107,8 +1107,7 @@ const updateExistingDataStream = async ({
() =>
esClient.indices.putMapping({
index: dataStreamName,
// @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584
body: mappings,
...mappings,
write_index_only: true,
}),
{ logger }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,21 +383,19 @@ _meta:
expect(esClient.indices.putIndexTemplate.mock.calls).toEqual([
[
{
body: {
_meta: meta,
composed_of: [
'logs-endpoint.metadata_current-template@package',
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
index_patterns: ['.metrics-endpoint.metadata_united_default'],
priority: 250,
template: { mappings: undefined, settings: undefined },
ignore_missing_component_templates: [
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
},
_meta: meta,
composed_of: [
'logs-endpoint.metadata_current-template@package',
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
index_patterns: ['.metrics-endpoint.metadata_united_default'],
priority: 250,
template: { mappings: undefined, settings: undefined },
ignore_missing_component_templates: [
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
name: 'logs-endpoint.metadata_current-template',
},
{ ignore: [404] },
Expand Down Expand Up @@ -673,21 +671,19 @@ _meta:
expect(esClient.indices.putIndexTemplate.mock.calls).toEqual([
[
{
body: {
_meta: meta,
composed_of: [
'logs-endpoint.metadata_current-template@package',
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
index_patterns: ['.metrics-endpoint.metadata_united_default'],
priority: 250,
template: { mappings: undefined, settings: undefined },
ignore_missing_component_templates: [
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
},
_meta: meta,
composed_of: [
'logs-endpoint.metadata_current-template@package',
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
index_patterns: ['.metrics-endpoint.metadata_united_default'],
priority: 250,
template: { mappings: undefined, settings: undefined },
ignore_missing_component_templates: [
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
name: 'logs-endpoint.metadata_current-template',
},
{ ignore: [404] },
Expand Down Expand Up @@ -940,21 +936,19 @@ _meta:
expect(esClient.indices.putIndexTemplate.mock.calls).toEqual([
[
{
body: {
_meta: meta,
composed_of: [
'logs-endpoint.metadata_current-template@package',
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
index_patterns: ['.metrics-endpoint.metadata_united_default'],
priority: 250,
template: { mappings: undefined, settings: undefined },
ignore_missing_component_templates: [
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
},
_meta: meta,
composed_of: [
'logs-endpoint.metadata_current-template@package',
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
index_patterns: ['.metrics-endpoint.metadata_united_default'],
priority: 250,
template: { mappings: undefined, settings: undefined },
ignore_missing_component_templates: [
'endpoint@custom',
'logs-endpoint.metadata_current-template@custom',
],
name: 'logs-endpoint.metadata_current-template',
},
{ ignore: [404] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,10 @@ describe('experimental_datastream_features', () => {
expect(esClient.cluster.getComponentTemplate).toHaveBeenCalled();
expect(esClient.cluster.putComponentTemplate).toHaveBeenCalledWith(
expect.objectContaining({
body: expect.objectContaining({
template: expect.objectContaining({
settings: expect.objectContaining({
index: expect.objectContaining({
mapping: expect.objectContaining({ source: { mode: 'synthetic' } }),
}),
template: expect.objectContaining({
settings: expect.objectContaining({
index: expect.objectContaining({
mapping: expect.objectContaining({ source: { mode: 'synthetic' } }),
}),
}),
}),
Expand All @@ -296,15 +294,13 @@ describe('experimental_datastream_features', () => {
expect(esClient.cluster.getComponentTemplate).toHaveBeenCalled();
expect(esClient.cluster.putComponentTemplate).toHaveBeenCalledWith(
expect.objectContaining({
body: expect.objectContaining({
template: expect.objectContaining({
mappings: expect.objectContaining({
properties: expect.objectContaining({
sequence: {
type: 'long',
index: false,
},
}),
template: expect.objectContaining({
mappings: expect.objectContaining({
properties: expect.objectContaining({
sequence: {
type: 'long',
index: false,
},
}),
}),
}),
Expand All @@ -326,15 +322,13 @@ describe('experimental_datastream_features', () => {
expect(esClient.cluster.getComponentTemplate).toHaveBeenCalled();
expect(esClient.cluster.putComponentTemplate).toHaveBeenCalledWith(
expect.objectContaining({
body: expect.objectContaining({
template: expect.objectContaining({
mappings: expect.objectContaining({
properties: expect.objectContaining({
name: {
type: 'keyword',
index: false,
},
}),
template: expect.objectContaining({
mappings: expect.objectContaining({
properties: expect.objectContaining({
name: {
type: 'keyword',
index: false,
},
}),
}),
}),
Expand All @@ -356,14 +350,12 @@ describe('experimental_datastream_features', () => {
expect(esClient.cluster.getComponentTemplate).toHaveBeenCalled();
expect(esClient.cluster.putComponentTemplate).toHaveBeenCalledWith(
expect.objectContaining({
body: expect.objectContaining({
template: expect.objectContaining({
mappings: expect.objectContaining({
properties: expect.objectContaining({
'@timestamp': {
type: 'date',
},
}),
template: expect.objectContaining({
mappings: expect.objectContaining({
properties: expect.objectContaining({
'@timestamp': {
type: 'date',
},
}),
}),
}),
Expand All @@ -385,11 +377,9 @@ describe('experimental_datastream_features', () => {
expect(esClient.indices.getIndexTemplate).toHaveBeenCalled();
expect(esClient.indices.putIndexTemplate).toHaveBeenCalledWith(
expect.objectContaining({
body: expect.objectContaining({
template: expect.objectContaining({
settings: expect.objectContaining({
index: { mode: 'time_series' },
}),
template: expect.objectContaining({
settings: expect.objectContaining({
index: { mode: 'time_series' },
}),
}),
_meta: { has_experimental_data_stream_indexing_features: true },
Expand Down Expand Up @@ -485,12 +475,10 @@ describe('experimental_datastream_features', () => {
expect(esClient.cluster.getComponentTemplate).toHaveBeenCalled();
expect(esClient.cluster.putComponentTemplate).toHaveBeenCalledWith(
expect.objectContaining({
body: expect.objectContaining({
template: expect.objectContaining({
settings: expect.objectContaining({
index: expect.objectContaining({
mapping: expect.objectContaining({ source: { mode: 'synthetic' } }),
}),
template: expect.objectContaining({
settings: expect.objectContaining({
index: expect.objectContaining({
mapping: expect.objectContaining({ source: { mode: 'synthetic' } }),
}),
}),
}),
Expand All @@ -512,15 +500,13 @@ describe('experimental_datastream_features', () => {
expect(esClient.cluster.getComponentTemplate).toHaveBeenCalled();
expect(esClient.cluster.putComponentTemplate).toHaveBeenCalledWith(
expect.objectContaining({
body: expect.objectContaining({
template: expect.objectContaining({
mappings: expect.objectContaining({
properties: expect.objectContaining({
sequence: {
type: 'long',
index: false,
},
}),
template: expect.objectContaining({
mappings: expect.objectContaining({
properties: expect.objectContaining({
sequence: {
type: 'long',
index: false,
},
}),
}),
}),
Expand All @@ -542,15 +528,13 @@ describe('experimental_datastream_features', () => {
expect(esClient.cluster.getComponentTemplate).toHaveBeenCalled();
expect(esClient.cluster.putComponentTemplate).toHaveBeenCalledWith(
expect.objectContaining({
body: expect.objectContaining({
template: expect.objectContaining({
mappings: expect.objectContaining({
properties: expect.objectContaining({
name: {
type: 'keyword',
index: false,
},
}),
template: expect.objectContaining({
mappings: expect.objectContaining({
properties: expect.objectContaining({
name: {
type: 'keyword',
index: false,
},
}),
}),
}),
Expand Down Expand Up @@ -588,11 +572,9 @@ describe('experimental_datastream_features', () => {
expect(esClient.indices.getIndexTemplate).toHaveBeenCalled();
expect(esClient.indices.putIndexTemplate).toHaveBeenCalledWith(
expect.objectContaining({
body: expect.objectContaining({
template: expect.objectContaining({
settings: expect.objectContaining({
index: { mode: 'time_series' },
}),
template: expect.objectContaining({
settings: expect.objectContaining({
index: { mode: 'time_series' },
}),
}),
_meta: { has_experimental_data_stream_indexing_features: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ export async function handleExperimentalDatastreamFeatureOptIn({

await esClient.cluster.putComponentTemplate({
name: componentTemplateName,
// @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584
body,
...body,
_meta: {
has_experimental_data_stream_indexing_features: hasExperimentalDataStreamIndexingFeatures,
},
Expand All @@ -211,7 +210,7 @@ export async function handleExperimentalDatastreamFeatureOptIn({
settings: {
...(indexTemplate.template?.settings ?? {}),
index: {
mode: featureMapEntry.features.tsdb ? 'time_series' : null,
mode: featureMapEntry.features.tsdb ? 'time_series' : undefined,
},
},
},
Expand All @@ -221,11 +220,14 @@ export async function handleExperimentalDatastreamFeatureOptIn({

await esClient.indices.putIndexTemplate({
name: featureMapEntry.data_stream,
// @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584
body: indexTemplateBody,
...indexTemplateBody,
_meta: {
has_experimental_data_stream_indexing_features: featureMapEntry.features.tsdb,
},
// GET brings string | string[] | undefined but this PUT expects string[]
ignore_missing_component_templates: indexTemplateBody.ignore_missing_component_templates
? [indexTemplateBody.ignore_missing_component_templates].flat()
: undefined,
});
}

Expand Down
Loading