Skip to content
Closed
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"@elastic/apm-rum-react": "^1.2.5",
"@elastic/charts": "28.2.0",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath/npm_module",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@7.13.0-canary.1",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@7.13.0-canary.4",
"@elastic/ems-client": "7.13.0",
"@elastic/eui": "32.1.0",
"@elastic/filesaver": "1.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/src/lib/indices/delete_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export async function waitForSnapshotCompletion(
}
);

return inProgressSnapshots;
return inProgressSnapshots ?? [];
};

const { body: repositoryMap } = await client.snapshot.getRepository({} as any);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('ElasticIndex', () => {
return elasticsearchClientMock.createSuccessTransportRequestPromise({
[index]: {
aliases: { foo: index },
mappings: { dynamic: 'strict', properties: { a: 'b' } },
mappings: { dynamic: 'strict', properties: { a: { type: 'flattened' } } },
settings: {},
},
} as estypes.GetIndexResponse);
Expand All @@ -49,7 +49,7 @@ describe('ElasticIndex', () => {
const info = await Index.fetchInfo(client, '.baz');
expect(info).toEqual({
aliases: { foo: '.baz' },
mappings: { dynamic: 'strict', properties: { a: 'b' } },
mappings: { dynamic: 'strict', properties: { a: { type: 'flattened' } } },
exists: true,
indexName: '.baz',
settings: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export async function createIndex(
mappings?: IndexMapping
) {
await client.indices.create({
body: { mappings, settings },
body: { mappings: mappings as estypes.TypeMapping, settings },
index,
});
}
Expand All @@ -283,7 +283,7 @@ export async function convertToAlias(
script?: string
) {
await client.indices.create({
body: { mappings: info.mappings, settings },
body: { mappings: info.mappings as estypes.TypeMapping, settings },
index: info.indexName,
});

Expand Down Expand Up @@ -406,7 +406,6 @@ async function reindex(
task_id: String(task),
});

// @ts-expect-error @elastic/elasticsearch GetTaskResponse doesn't contain `error` property
const e = body.error;
if (e) {
throw new Error(`Re-index failed [${e.type}] ${e.reason} :: ${JSON.stringify(e)}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { loggingSystemMock } from '../../../logging/logging_system.mock';
import { SavedObjectTypeRegistry } from '../../saved_objects_type_registry';
import { SavedObjectsType } from '../../types';
import { DocumentMigrator } from '../core/document_migrator';

jest.mock('../core/document_migrator', () => {
return {
// Create a mock for spying on the constructor
Expand Down Expand Up @@ -362,7 +363,11 @@ const mockV2MigrationOptions = () => {
)
);
options.client.indices.addBlock.mockReturnValue(
elasticsearchClientMock.createSuccessTransportRequestPromise({ acknowledged: true })
elasticsearchClientMock.createSuccessTransportRequestPromise({
acknowledged: true,
shards_acknowledged: true,
indices: [],
})
);
options.client.reindex.mockReturnValue(
elasticsearchClientMock.createSuccessTransportRequestPromise({
Expand Down
12 changes: 7 additions & 5 deletions src/core/server/saved_objects/migrationsv2/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
catchRetryableEsClientErrors,
RetryableEsClientError,
} from './catch_retryable_es_client_errors';

export type { RetryableEsClientError };

/**
Expand Down Expand Up @@ -90,6 +91,7 @@ export interface IndexNotFound {
type: 'index_not_found_exception';
index: string;
}

/**
* Sets a write block in place for the given index. If the response includes
* `acknowledged: true` all in-progress writes have drained and no further
Expand Down Expand Up @@ -305,7 +307,7 @@ export const cloneIndex = (
};

interface WaitForTaskResponse {
error: Option.Option<{ type: string; reason: string; index: string }>;
error: Option.Option<{ type: string; reason: string; index?: string }>;
completed: boolean;
failures: Option.Option<any[]>;
description?: string;
Expand Down Expand Up @@ -367,7 +369,6 @@ const waitForTask = (
const failures = body.response?.failures ?? [];
return Either.right({
completed: body.completed,
// @ts-expect-error @elastic/elasticsearch GetTaskResponse doesn't declare `error` property
error: Option.fromNullable(body.error),
failures: failures.length > 0 ? Option.some(failures) : Option.none,
description: body.task.description,
Expand Down Expand Up @@ -523,7 +524,7 @@ export const waitForReindexTask = flow(
if (res.error.value.type === 'index_not_found_exception') {
return TaskEither.left({
type: 'index_not_found_exception' as const,
index: res.error.value.index,
index: res.error.value.index ?? 'unknown',
});
} else {
throw new Error('Reindex failed with the following error:\n' + JSON.stringify(res.error));
Expand Down Expand Up @@ -720,7 +721,7 @@ export const createIndex = (
// started
timeout: DEFAULT_TIMEOUT,
body: {
mappings,
mappings: mappings as estypes.TypeMapping,
aliases: aliasesObject,
settings: {
index: {
Expand Down Expand Up @@ -813,7 +814,7 @@ export const updateAndPickupMappings = (
.putMapping({
index,
timeout: DEFAULT_TIMEOUT,
body: mappings,
body: mappings as estypes.TypeMapping,
})
.then((res) => {
// Ignore `acknowledged: false`. When the coordinating node accepts
Expand Down Expand Up @@ -842,6 +843,7 @@ export const updateAndPickupMappings = (
})
);
};

export interface SearchResponse {
outdatedDocuments: SavedObjectsRawDoc[];
}
Expand Down
12 changes: 3 additions & 9 deletions src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,6 @@ export class SavedObjectsRepository {
}

const deleteDocNotFound = body.result === 'not_found';
// @ts-expect-error 'error' does not exist on type 'DeleteResponse'
const deleteIndexNotFound = body.error && body.error.type === 'index_not_found_exception';
if (deleteDocNotFound || deleteIndexNotFound) {
// see "404s from missing index" above
Expand Down Expand Up @@ -1386,7 +1385,6 @@ export class SavedObjectsRepository {
}

const deleteDocNotFound = body.result === 'not_found';
// @ts-expect-error
const deleteIndexNotFound = body.error && body.error.type === 'index_not_found_exception';
if (deleteDocNotFound || deleteIndexNotFound) {
// see "404s from missing index" above
Expand Down Expand Up @@ -1920,13 +1918,9 @@ export class SavedObjectsRepository {
const {
body,
statusCode,
} = await this.client.openPointInTime<SavedObjectsOpenPointInTimeResponse>(
// @ts-expect-error @elastic/elasticsearch OpenPointInTimeRequest.index expected to accept string[]
esOptions,
{
ignore: [404],
}
);
} = await this.client.openPointInTime<SavedObjectsOpenPointInTimeResponse>(esOptions, {
ignore: [404],
});
if (statusCode === 404) {
throw SavedObjectsErrorHelpers.createGenericNotFoundError();
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1389,10 +1389,10 @@
version "0.0.0"
uid ""

"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@7.13.0-canary.1":
version "7.13.0-canary.1"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-7.13.0-canary.1.tgz#53a8ddbaeaba77dc163aad972e56d6741c98858a"
integrity sha512-RqJxZyouL/lTN4EgBvN9xQKq0zUIzSUAks91q/UvM41XyATTeTa2e9+zxrK07JCi0R6l/xAlHrLglf1/LiJOyg==
"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@7.13.0-canary.4":
version "7.13.0-canary.4"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-7.13.0-canary.4.tgz#10c321e6a268ffa2090d5b585fe5bf5e17ac840f"
integrity sha512-EIbT252HbTktRgYnJ06YXz+E6iRudhT6wBckOngAcycyfsjL8T8sVlE4EtyFKsgQUacjIEt2g7ZB43AJc4218Q==
dependencies:
debug "^4.3.1"
hpagent "^0.1.1"
Expand Down