Skip to content

Commit

Permalink
[Ingest]: ignore 404, check if there are transforms in results. (#80721
Browse files Browse the repository at this point in the history
…) (#80853)

[Ingest]: ignore 404, check if there are transforms in results
  • Loading branch information
nnamdifrankie authored Oct 16, 2020
1 parent 5be73e6 commit 494c4e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -28,14 +29,15 @@ export const deleteTransforms = async (
// get the index the transform
const transformResponse: {
count: number;
transforms: Array<{
transforms?: Array<{
dest: {
index: string;
};
}>;
} = await callCluster('transport.request', {
method: 'GET',
path: `/_transform/${transformId}`,
ignore: [404],
});

await stopTransforms([transformId], callCluster);
Expand All @@ -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}`);
}
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ describe('test transform install', () => {
{
method: 'GET',
path: '/_transform/endpoint.metadata_current-default-0.15.0-dev.0',
ignore: [404],
},
],
[
Expand Down Expand Up @@ -446,6 +447,7 @@ describe('test transform install', () => {
{
method: 'GET',
path: '/_transform/endpoint.metadata-current-default-0.15.0-dev.0',
ignore: [404],
},
],
[
Expand Down

0 comments on commit 494c4e2

Please sign in to comment.