Skip to content
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 @@ -85,6 +85,9 @@ export const getSLOPipelineId = (sloId: string, sloRevision: number) =>
export const getSLOSummaryPipelineId = (sloId: string, sloRevision: number) =>
`.slo-observability.summary.pipeline-${sloId}-${sloRevision}`;

export const getWildcardPipelineId = (sloId: string, sloRevision: number) =>
`.slo-observability.*.pipeline-${sloId}-${sloRevision}`;

export const SYNTHETICS_INDEX_PATTERN = 'synthetics-*';
export const SYNTHETICS_DEFAULT_GROUPINGS = ['monitor.name', 'observer.geo.name', 'monitor.id'];

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ describe('DeleteSLO', () => {
await deleteSLO.execute(slo.id);

expect(mockRepository.findById).toMatchSnapshot();
expect(mockSummaryTransformManager.stop).toMatchSnapshot();
expect(mockSummaryTransformManager.uninstall).toMatchSnapshot();
expect(mockTransformManager.stop).toMatchSnapshot();
expect(mockTransformManager.uninstall).toMatchSnapshot();
expect(mockScopedClusterClient.asSecondaryAuthUser.ingest.deletePipeline).toMatchSnapshot();
expect(mockEsClient.deleteByQuery).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
import { RulesClientApi } from '@kbn/alerting-plugin/server/types';
import { ElasticsearchClient, IScopedClusterClient } from '@kbn/core/server';
import {
getSLOPipelineId,
getSLOSummaryPipelineId,
getSLOSummaryTransformId,
getSLOTransformId,
SLI_DESTINATION_INDEX_PATTERN,
SUMMARY_DESTINATION_INDEX_PATTERN,
getSLOSummaryTransformId,
getSLOTransformId,
getWildcardPipelineId,
} from '../../common/constants';
import { SLODefinition } from '../domain/models';
import { retryTransientEsErrors } from '../utils/retry';
import { SLORepository } from './slo_repository';
import { TransformManager } from './transform_manager';
import { SLODefinition } from '../domain/models';

export class DeleteSLO {
constructor(
Expand All @@ -35,20 +34,12 @@ export class DeleteSLO {

await Promise.all([this.deleteSummaryTransform(slo), this.deleteRollupTransform(slo)]);

await Promise.all([
retryTransientEsErrors(() =>
this.scopedClusterClient.asSecondaryAuthUser.ingest.deletePipeline(
{ id: getSLOPipelineId(slo.id, slo.revision) },
{ ignore: [404] }
)
),
retryTransientEsErrors(() =>
this.scopedClusterClient.asSecondaryAuthUser.ingest.deletePipeline(
{ id: getSLOSummaryPipelineId(slo.id, slo.revision) },
{ ignore: [404] }
)
),
]);
await retryTransientEsErrors(() =>
this.scopedClusterClient.asSecondaryAuthUser.ingest.deletePipeline(
{ id: getWildcardPipelineId(slo.id, slo.revision) },
{ ignore: [404] }
)
);

await Promise.all([
this.deleteRollupData(slo.id),
Expand All @@ -60,13 +51,11 @@ export class DeleteSLO {

private async deleteRollupTransform(slo: SLODefinition) {
const rollupTransformId = getSLOTransformId(slo.id, slo.revision);
await this.transformManager.stop(rollupTransformId);
await this.transformManager.uninstall(rollupTransformId);
}

private async deleteSummaryTransform(slo: SLODefinition) {
const summaryTransformId = getSLOSummaryTransformId(slo.id, slo.revision);
await this.summaryTransformManager.stop(summaryTransformId);
await this.summaryTransformManager.uninstall(summaryTransformId);
}

Expand All @@ -77,8 +66,12 @@ export class DeleteSLO {
conflicts: 'proceed',
slices: 'auto',
query: {
match: {
'slo.id': sloId,
bool: {
filter: {
term: {
'slo.id': sloId,
},
},
},
},
});
Expand All @@ -92,8 +85,12 @@ export class DeleteSLO {
conflicts: 'proceed',
slices: 'auto',
query: {
match: {
'slo.id': sloId,
bool: {
filter: {
term: {
'slo.id': sloId,
},
},
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ describe('ResetSLO', () => {
await resetSLO.execute(slo.id);

// delete existing resources and data
expect(mockSummaryTransformManager.stop).toMatchSnapshot();
expect(mockSummaryTransformManager.uninstall).toMatchSnapshot();

expect(mockTransformManager.stop).toMatchSnapshot();
expect(mockTransformManager.uninstall).toMatchSnapshot();

expect(mockEsClient.deleteByQuery).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import {
SLO_MODEL_VERSION,
SUMMARY_DESTINATION_INDEX_PATTERN,
SUMMARY_TEMP_INDEX_NAME,
getSLOPipelineId,
getSLOSummaryPipelineId,
getSLOSummaryTransformId,
getSLOTransformId,
getWildcardPipelineId,
} from '../../common/constants';
import { getSLIPipelineTemplate } from '../assets/ingest_templates/sli_pipeline_template';
import { getSummaryPipelineTemplate } from '../assets/ingest_templates/summary_pipeline_template';
Expand Down Expand Up @@ -43,11 +42,9 @@ export class ResetSLO {
await assertExpectedIndicatorSourceIndexPrivileges(slo, this.esClient);

const summaryTransformId = getSLOSummaryTransformId(slo.id, slo.revision);
await this.summaryTransformManager.stop(summaryTransformId);
await this.summaryTransformManager.uninstall(summaryTransformId);

const rollupTransformId = getSLOTransformId(slo.id, slo.revision);
await this.transformManager.stop(rollupTransformId);
await this.transformManager.uninstall(rollupTransformId);

await Promise.all([this.deleteRollupData(slo.id), this.deleteSummaryData(slo.id)]);
Expand Down Expand Up @@ -90,17 +87,10 @@ export class ResetSLO {
`Cannot reset the SLO [id: ${slo.id}, revision: ${slo.revision}]. Rolling back. ${err}`
);

await this.summaryTransformManager.stop(summaryTransformId);
await this.summaryTransformManager.uninstall(summaryTransformId);
await this.transformManager.stop(rollupTransformId);
await this.transformManager.uninstall(rollupTransformId);
await this.scopedClusterClient.asSecondaryAuthUser.ingest.deletePipeline(
{ id: getSLOSummaryPipelineId(slo.id, slo.revision) },
{ ignore: [404] }
);

await this.scopedClusterClient.asSecondaryAuthUser.ingest.deletePipeline(
{ id: getSLOPipelineId(slo.id, slo.revision) },
{ id: getWildcardPipelineId(slo.id, slo.revision) },
{ ignore: [404] }
);

Expand Down
Loading