Skip to content

Commit

Permalink
[Fleet] Silently swallow 404 errors when deleting ingest pipelines (#…
Browse files Browse the repository at this point in the history
…91778)

* Only show transform logs when there are transforms

* Silently swallow 404 errors when deleting ingest pipelines

* Change to IngestManagerError
  • Loading branch information
jen-huang authored Feb 18, 2021
1 parent 2408d00 commit 0f80467
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { SavedObjectsClientContract } from 'src/core/server';
import { appContextService } from '../../../';
import { CallESAsCurrentUser, ElasticsearchAssetType } from '../../../../types';
import { IngestManagerError } from '../../../../errors';
import { getInstallation } from '../../packages/get';
import { PACKAGES_SAVED_OBJECT_TYPE, EsAssetReference } from '../../../../../common';

Expand Down Expand Up @@ -61,7 +62,11 @@ export async function deletePipeline(callCluster: CallESAsCurrentUser, id: strin
try {
await callCluster('ingest.deletePipeline', { id });
} catch (err) {
throw new Error(`error deleting pipeline ${id}`);
// Only throw if error is not a 404 error. Sometimes the pipeline is already deleted, but we have
// duplicate references to them, see https://github.com/elastic/kibana/issues/91192
if (err.statusCode !== 404) {
throw new IngestManagerError(`error deleting pipeline ${id}: ${err}`);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ export const installTransform = async (
previousInstalledTransformEsAssets = installation.installed_es.filter(
({ type, id }) => type === ElasticsearchAssetType.transform
);
logger.info(
`Found previous transform references:\n ${JSON.stringify(previousInstalledTransformEsAssets)}`
);
if (previousInstalledTransformEsAssets.length) {
logger.info(
`Found previous transform references:\n ${JSON.stringify(
previousInstalledTransformEsAssets
)}`
);
}
}

// delete all previous transform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export const deleteTransforms = async (
transformIds: string[]
) => {
const logger = appContextService.getLogger();
logger.info(`Deleting currently installed transform ids ${transformIds}`);
if (transformIds.length) {
logger.info(`Deleting currently installed transform ids ${transformIds}`);
}
await Promise.all(
transformIds.map(async (transformId) => {
// get the index the transform
Expand Down

0 comments on commit 0f80467

Please sign in to comment.