Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
don't load traces if only remediation title is need. remeditation tit…
Browse files Browse the repository at this point in the history
…le is now provided with GET /sequence endpoint

Signed-off-by: ermin.muratovic <[email protected]>
  • Loading branch information
ermin-muratovic committed Dec 16, 2021
1 parent dca04ea commit 3203172
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions bridge/server/services/data-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,46 +351,39 @@ export class DataService {
const stage = { ...sequence.stages[0], actions: [] };
const remediation: Remediation = Remediation.fromJSON({ ...sequence, stages: [stage] });

await this.setRemediationDetails(
remediation,
includeProblemTitle,
includeActions,
projectName,
stageName,
sequence.service,
sequence.shkeptncontext
);
if (includeActions) {
await this.loadRemediationActions(
remediation,
projectName,
stageName,
sequence.service,
sequence.shkeptncontext
);
}
remediations.push(remediation);
}
}
return remediations;
}

private async setRemediationDetails(
private async loadRemediationActions(
remediation: Remediation,
includeProblemTitle: boolean,
includeActions: boolean,
projectName: string,
stageName: string,
serviceName: string,
keptnContext: string
): Promise<void> {
if (includeProblemTitle) {
const response = await this.apiService.getTraces(
includeActions ? undefined : `${EventTypes.PREFIX}${stageName}.remediation.triggered`,
this.MAX_TRACE_PAGE_SIZE,
projectName,
stageName,
serviceName,
keptnContext
);
const traces = response.data.events;
remediation.problemTitle = traces[traces.length - 1]?.data.problem?.ProblemTitle;
if (includeActions) {
const actions = this.getRemediationActions(Trace.traceMapper(traces));
remediation.stages[0].actions.push(...actions);
}
}
const response = await this.apiService.getTraces(
`${EventTypes.PREFIX}${stageName}.remediation.triggered`,
this.MAX_TRACE_PAGE_SIZE,
projectName,
stageName,
serviceName,
keptnContext
);
const traces = response.data.events;
const actions = this.getRemediationActions(Trace.traceMapper(traces));
remediation.stages[0].actions.push(...actions);
}

private getRemediationActions(traces: Trace[]): IRemediationAction[] {
Expand Down

0 comments on commit 3203172

Please sign in to comment.