Skip to content

Commit

Permalink
migrationsv1: ignore tsvb-validation-telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed Apr 8, 2021
1 parent 8861c86 commit 259308c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,18 @@ describe('ElasticIndex', () => {
size: 100,
query: {
bool: {
must_not: {
term: {
type: 'fleet-agent-events',
must_not: [
{
term: {
type: 'fleet-agent-events',
},
},
},
{
term: {
type: 'tsvb-validation-telemetry',
},
},
],
},
},
},
Expand Down
23 changes: 13 additions & 10 deletions src/core/server/saved_objects/migrations/core/elastic_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,19 @@ export function reader(
let scrollId: string | undefined;

// When migrating from the outdated index we use a read query which excludes
// saved objects which are no longer used. These saved objects will still be
// kept in the outdated index for backup purposes, but won't be availble in
// the upgraded index.
const excludeUnusedTypes = {
// saved object types which are no longer used. These saved objects will
// still be kept in the outdated index for backup purposes, but won't be
// availble in the upgraded index.
const EXCLUDE_UNUSED_TYPES = [
'fleet-agent-events', // https://github.com/elastic/kibana/issues/91869
'tsvb-validation-telemetry', // https://github.com/elastic/kibana/issues/95617
];

const excludeUnusedTypesQuery = {
bool: {
must_not: {
term: {
type: 'fleet-agent-events', // https://github.com/elastic/kibana/issues/91869
},
},
must_not: EXCLUDE_UNUSED_TYPES.map((type) => ({
term: { type },
})),
},
};

Expand All @@ -92,7 +95,7 @@ export function reader(
: client.search<SearchResponse<SavedObjectsRawDocSource>>({
body: {
size: batchSize,
query: excludeUnusedTypes,
query: excludeUnusedTypesQuery,
},
index,
scroll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ describe('KibanaMigrator', () => {
options.client.tasks.get.mockReturnValue(
elasticsearchClientMock.createSuccessTransportRequestPromise({
completed: true,
error: { type: 'elatsicsearch_exception', reason: 'task failed with an error' },
error: { type: 'elasticsearch_exception', reason: 'task failed with an error' },
failures: [],
task: { description: 'task description' } as any,
})
Expand All @@ -331,11 +331,11 @@ describe('KibanaMigrator', () => {
migrator.prepareMigrations();
await expect(migrator.runMigrations()).rejects.toMatchInlineSnapshot(`
[Error: Unable to complete saved object migrations for the [.my-index] index. Error: Reindex failed with the following error:
{"_tag":"Some","value":{"type":"elatsicsearch_exception","reason":"task failed with an error"}}]
{"_tag":"Some","value":{"type":"elasticsearch_exception","reason":"task failed with an error"}}]
`);
expect(loggingSystemMock.collect(options.logger).error[0][0]).toMatchInlineSnapshot(`
[Error: Reindex failed with the following error:
{"_tag":"Some","value":{"type":"elatsicsearch_exception","reason":"task failed with an error"}}]
{"_tag":"Some","value":{"type":"elasticsearch_exception","reason":"task failed with an error"}}]
`);
});
});
Expand Down

0 comments on commit 259308c

Please sign in to comment.