[Ingest]: ignore 404, check if there are transforms in results. (#80721)

[Ingest]: ignore 404, check if there are transforms in results
This commit is contained in:
nnamdifrankie 2020-10-16 11:28:29 -04:00 committed by GitHub
parent 98c751a0f5
commit cba7e58482
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View file

@ -7,6 +7,7 @@
import { SavedObjectsClientContract } from 'kibana/server';
import { CallESAsCurrentUser, ElasticsearchAssetType, EsAssetReference } from '../../../../types';
import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../../../common/constants';
import { appContextService } from '../../../app_context';
export const stopTransforms = async (transformIds: string[], callCluster: CallESAsCurrentUser) => {
for (const transformId of transformIds) {
@ -28,7 +29,7 @@ export const deleteTransforms = async (
// get the index the transform
const transformResponse: {
count: number;
transforms: Array<{
transforms?: Array<{
dest: {
index: string;
};
@ -36,6 +37,7 @@ export const deleteTransforms = async (
} = await callCluster('transport.request', {
method: 'GET',
path: `/_transform/${transformId}`,
ignore: [404],
});
await stopTransforms([transformId], callCluster);
@ -46,13 +48,17 @@ export const deleteTransforms = async (
ignore: [404],
});
// expect this to be 1
for (const transform of transformResponse.transforms) {
await callCluster('transport.request', {
method: 'DELETE',
path: `/${transform?.dest?.index}`,
ignore: [404],
});
if (transformResponse?.transforms) {
// expect this to be 1
for (const transform of transformResponse.transforms) {
await callCluster('transport.request', {
method: 'DELETE',
path: `/${transform?.dest?.index}`,
ignore: [404],
});
}
} else {
appContextService.getLogger().warn(`cannot find transform for ${transformId}`);
}
})
);

View file

@ -160,6 +160,7 @@ describe('test transform install', () => {
{
method: 'GET',
path: '/_transform/endpoint.metadata_current-default-0.15.0-dev.0',
ignore: [404],
},
],
[
@ -446,6 +447,7 @@ describe('test transform install', () => {
{
method: 'GET',
path: '/_transform/endpoint.metadata-current-default-0.15.0-dev.0',
ignore: [404],
},
],
[