Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: add log statement when deleting transform #81927

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { CallESAsCurrentUser } from '../../../../types';
import { getInstallation } from '../../packages';
import { deleteTransforms, deleteTransformRefs } from './remove';
import { getAsset } from './common';
import { appContextService } from '../../../app_context';

interface TransformInstallation {
installationName: string;
Expand All @@ -29,6 +30,7 @@ export const installTransform = async (
callCluster: CallESAsCurrentUser,
savedObjectsClient: SavedObjectsClientContract
) => {
const logger = appContextService.getLogger();
const installation = await getInstallation({
savedObjectsClient,
pkgName: installablePackage.name,
Expand All @@ -38,6 +40,9 @@ export const installTransform = async (
previousInstalledTransformEsAssets = installation.installed_es.filter(
({ type, id }) => type === ElasticsearchAssetType.transform
);
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 @@ -24,6 +24,8 @@ export const deleteTransforms = async (
callCluster: CallESAsCurrentUser,
transformIds: string[]
) => {
const logger = appContextService.getLogger();
logger.info(`Deleting currently installed transform ids ${transformIds}`);
await Promise.all(
transformIds.map(async (transformId) => {
// get the index the transform
Expand All @@ -47,7 +49,7 @@ export const deleteTransforms = async (
path: `/_transform/${transformId}`,
ignore: [404],
});

logger.info(`Deleted: ${transformId}`);
if (transformResponse?.transforms) {
// expect this to be 1
for (const transform of transformResponse.transforms) {
Expand All @@ -58,7 +60,7 @@ export const deleteTransforms = async (
});
}
} else {
appContextService.getLogger().warn(`cannot find transform for ${transformId}`);
logger.warn(`cannot find transform for ${transformId}`);
}
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { createAppContextStartContractMock } from '../../../../mocks';

jest.mock('../../packages/get', () => {
return { getInstallation: jest.fn(), getInstallationObject: jest.fn() };
});
Expand All @@ -21,11 +23,13 @@ import { getInstallation, getInstallationObject } from '../../packages';
import { getAsset } from './common';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { savedObjectsClientMock } from '../../../../../../../../src/core/server/saved_objects/service/saved_objects_client.mock';
import { appContextService } from '../../../app_context';

describe('test transform install', () => {
let legacyScopedClusterClient: jest.Mocked<ILegacyScopedClusterClient>;
let savedObjectsClient: jest.Mocked<SavedObjectsClientContract>;
beforeEach(() => {
appContextService.start(createAppContextStartContractMock());
legacyScopedClusterClient = {
callAsInternalUser: jest.fn(),
callAsCurrentUser: jest.fn(),
Expand Down