Skip to content

Commit

Permalink
container process exited events. (#723)
Browse files Browse the repository at this point in the history
* container process exited events.

* added a test for new event.
  • Loading branch information
jeffj6123 authored May 24, 2022
1 parent d44d1ec commit 6c769ea
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 4 deletions.
45 changes: 42 additions & 3 deletions src/SfxWeb/src/app/Models/eventstore/timelineGenerator.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NodeTimelineGenerator, EventStoreUtils } from './timelineGenerators';
import { NodeEvent } from './Events';
import { NodeTimelineGenerator, EventStoreUtils, ApplicationTimelineGenerator } from './timelineGenerators';
import { ApplicationEvent, NodeEvent } from './Events';


describe('TimelineGenerators', () => {
Expand Down Expand Up @@ -215,5 +215,44 @@ describe('TimelineGenerators', () => {
expect(events.potentiallyMissingEvents).toBeFalse();
});
});
});

describe('Application', () => {

const generator = new ApplicationTimelineGenerator();

fit('container exit', () => {
const endDateRange = new Date('2020-10-17T05:41:22.8992645Z');

const containerExitEvent = new ApplicationEvent();
containerExitEvent.fillFromJSON({
"ServiceName": "fabric:/test",
"ServicePackageName": "test.HostPkg",
"ServicePackageActivationId": "b8505a1e-ac6f-43be-a76a-bc4652c98975",
"IsExclusive": true,
"CodePackageName": "Code",
"EntryPointType": "ContainerHost",
"ImageName": "somecontainer.net/image",
"ContainerName": "b8505a1e-ac6f-43be-a76a-bc4652c98975",
"HostId": "ffa6bc13-b8a2-44e8-8a00-fe707c9b63d7",
"ExitCode": 7147,
"UnexpectedTermination": false,
"StartTime": "2022-05-18T16:42:13Z",
"ExitReason": "The process/container terminated with exit code:7147. Restarting the container because HEALTHCHECK for Docker container ContainerName=-a76a-bc4652c98975, reported health_status=unhealthy, TimeStamp=2022-05-23 12:43:48.000.. For information about common termination errors, please visit https://aka.ms/service-fabric-termination-errors",
"ApplicationId": "testapp",
"Kind": "ApplicationContainerInstanceExited",
"EventInstanceId": "0dbbfb66-5e0c-40f0-af6b-249ffb4d5770",
"TimeStamp": "2022-05-23T12:44:30.929434Z",
"Category": "StateTransition",
"HasCorrelatedEvents": false
})

const data = [containerExitEvent];
const events = generator.consume(data, startDate, endDateRange);
expect(events.items.length).toBe(1);
expect(events.potentiallyMissingEvents).toBeFalse();
});
})

});


39 changes: 38 additions & 1 deletion src/SfxWeb/src/app/Models/eventstore/timelineGenerators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ export class ApplicationTimelineGenerator extends TimeLineGeneratorBase<Applicat
static readonly upgradeDomainLabel = 'Application Upgrade Domains';
static readonly applicationUpgradeLabel = 'Application Upgrades';
static readonly applicationPrcoessExitedLabel = 'Application Process Exited';
static readonly applicationContainerExitedLabel = 'Container Process Exited';

consume(events: ApplicationEvent[], startOfRange: Date, endOfRange: Date): ITimelineData {
const items = new DataSet<DataItem>();
Expand All @@ -464,6 +465,7 @@ export class ApplicationTimelineGenerator extends TimeLineGeneratorBase<Applicat
let upgradeApplicationStarted: ApplicationEvent;
const applicationRollBacks: Record<string, {complete: ApplicationEvent, start?: ApplicationEvent}> = {};
const processExitedGroups: Record<string, DataGroup> = {};
const containerExitedGroups: Record<string, DataGroup> = {};

events.forEach( event => {
// we want the oldest upgrade started before finding any previousApplicationUpgrade
Expand All @@ -477,6 +479,8 @@ export class ApplicationTimelineGenerator extends TimeLineGeneratorBase<Applicat
previousApplicationUpgrade = event;
}else if (event.kind === 'ApplicationProcessExited') {
this.parseApplicationProcessExited(event, items, processExitedGroups);
}else if(event.kind === "ApplicationContainerInstanceExited") {
this.parseApplicationProcessExited(event, items, containerExitedGroups);
}

// handle roll backs alone
Expand Down Expand Up @@ -517,9 +521,23 @@ export class ApplicationTimelineGenerator extends TimeLineGeneratorBase<Applicat

groups.add(nestedApplicationProcessExited);

const nestedContainerProcessExited: DataGroup = {
id: ApplicationTimelineGenerator.applicationContainerExitedLabel,
nestedGroups: [],
content: ApplicationTimelineGenerator.applicationContainerExitedLabel,
};

Object.keys(containerExitedGroups).forEach(groupName => {
nestedContainerProcessExited.nestedGroups.push(groupName);
groups.add(containerExitedGroups[groupName]);
});

groups.add(nestedContainerProcessExited);

return {
groups,
items
items,
potentiallyMissingEvents: false
};
}

Expand All @@ -542,6 +560,25 @@ export class ApplicationTimelineGenerator extends TimeLineGeneratorBase<Applicat
title: EventStoreUtils.tooltipFormat(event.eventProperties, start, null, 'Primary swap to ' + label),
});
}

parseContainerExited(event: FabricEventBase, items: DataSet<DataItem>, processExitedGroups: Record<string, DataGroup>) {

const groupLabel = `${event.eventProperties.ServicePackageName}`;
processExitedGroups[groupLabel] = {id: groupLabel, content: groupLabel};

const start = event.timeStamp;
const label = event.eventProperties.ExeName;

items.add({
id: event.eventInstanceId + label,
content: '',
start,
group: groupLabel,
type: 'point',
className: event.eventProperties.UnexpectedTermination ? 'red-point' : 'green-point',
title: EventStoreUtils.tooltipFormat(event.eventProperties, event.timeStamp),
});
}
}

export class PartitionTimelineGenerator extends TimeLineGeneratorBase<PartitionEvent> {
Expand Down

0 comments on commit 6c769ea

Please sign in to comment.