cleanup
parent
f57f11449f
commit
981a8eedf2
|
|
@ -470,6 +470,10 @@ class AWS {
|
||||||
}
|
}
|
||||||
static setupCloudFormations(CF, buildUid, stackName, image, entrypoint, commands, mountdir, workingdir, secrets) {
|
static setupCloudFormations(CF, buildUid, stackName, image, entrypoint, commands, mountdir, workingdir, secrets) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const logid = nanoid_1.customAlphabet(alphabet, 9)();
|
||||||
|
commands[1] += `
|
||||||
|
echo "${logid}"
|
||||||
|
`;
|
||||||
const taskDefStackName = `${stackName}-${buildUid}`;
|
const taskDefStackName = `${stackName}-${buildUid}`;
|
||||||
const taskDefCloudFormation = fs.readFileSync(`${__dirname}/task-def-formation.yml`, 'utf8');
|
const taskDefCloudFormation = fs.readFileSync(`${__dirname}/task-def-formation.yml`, 'utf8');
|
||||||
yield CF.createStack({
|
yield CF.createStack({
|
||||||
|
|
@ -553,6 +557,7 @@ class AWS {
|
||||||
ttlCloudFormation: cleanupCloudFormation,
|
ttlCloudFormation: cleanupCloudFormation,
|
||||||
taskDefResources,
|
taskDefResources,
|
||||||
baseResources,
|
baseResources,
|
||||||
|
logid,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -656,7 +661,8 @@ class AWS {
|
||||||
yield new Promise((resolve) => setTimeout(resolve, 1500));
|
yield new Promise((resolve) => setTimeout(resolve, 1500));
|
||||||
if ((yield getTaskStatus()) !== 'RUNNING') {
|
if ((yield getTaskStatus()) !== 'RUNNING') {
|
||||||
readingLogs = false;
|
readingLogs = false;
|
||||||
yield new Promise((resolve) => setTimeout(resolve, 35000));
|
core.info('Task status is not RUNNING waiting 45 seconds for end of logs.');
|
||||||
|
yield new Promise((resolve) => setTimeout(resolve, 45000));
|
||||||
}
|
}
|
||||||
const records = yield kinesis
|
const records = yield kinesis
|
||||||
.getRecords({
|
.getRecords({
|
||||||
|
|
@ -670,12 +676,15 @@ class AWS {
|
||||||
if (json.messageType === 'DATA_MESSAGE') {
|
if (json.messageType === 'DATA_MESSAGE') {
|
||||||
for (let logEventsIndex = 0; logEventsIndex < json.logEvents.length; logEventsIndex++) {
|
for (let logEventsIndex = 0; logEventsIndex < json.logEvents.length; logEventsIndex++) {
|
||||||
core.info(json.logEvents[logEventsIndex].message);
|
core.info(json.logEvents[logEventsIndex].message);
|
||||||
|
if (json.logEvents[logEventsIndex].message.includes(taskDef.logid)) {
|
||||||
|
core.info('End of task logs');
|
||||||
|
readingLogs = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.info('End of task logs');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static cleanupResources(CF, taskDef) {
|
static cleanupResources(CF, taskDef) {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -416,6 +416,7 @@ class AWS {
|
||||||
ttlCloudFormation: cleanupCloudFormation,
|
ttlCloudFormation: cleanupCloudFormation,
|
||||||
taskDefResources,
|
taskDefResources,
|
||||||
baseResources,
|
baseResources,
|
||||||
|
logid,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -476,7 +477,7 @@ class AWS {
|
||||||
core.error(error);
|
core.error(error);
|
||||||
}
|
}
|
||||||
core.info(`Task is running on worker cluster`);
|
core.info(`Task is running on worker cluster`);
|
||||||
await this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName, logid);
|
await this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName);
|
||||||
await ECS.waitFor('tasksStopped', { cluster, tasks: [taskArn] }).promise();
|
await ECS.waitFor('tasksStopped', { cluster, tasks: [taskArn] }).promise();
|
||||||
const exitCode = (
|
const exitCode = (
|
||||||
await ECS.describeTasks({
|
await ECS.describeTasks({
|
||||||
|
|
@ -497,7 +498,7 @@ class AWS {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async streamLogsUntilTaskStops(ECS, CF, taskDef, clusterName, taskArn, kinesisStreamName, logid) {
|
static async streamLogsUntilTaskStops(ECS, CF, taskDef, clusterName, taskArn, kinesisStreamName) {
|
||||||
// watching logs
|
// watching logs
|
||||||
const kinesis = new SDK.Kinesis();
|
const kinesis = new SDK.Kinesis();
|
||||||
|
|
||||||
|
|
@ -555,7 +556,8 @@ class AWS {
|
||||||
if (json.messageType === 'DATA_MESSAGE') {
|
if (json.messageType === 'DATA_MESSAGE') {
|
||||||
for (let logEventsIndex = 0; logEventsIndex < json.logEvents.length; logEventsIndex++) {
|
for (let logEventsIndex = 0; logEventsIndex < json.logEvents.length; logEventsIndex++) {
|
||||||
core.info(json.logEvents[logEventsIndex].message);
|
core.info(json.logEvents[logEventsIndex].message);
|
||||||
if (json.logEvents[logEventsIndex].message.includes(logid)) {
|
if (json.logEvents[logEventsIndex].message.includes(taskDef.logid)) {
|
||||||
|
core.info('End of task logs');
|
||||||
readingLogs = false;
|
readingLogs = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -563,7 +565,6 @@ class AWS {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.info('End of task logs');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async cleanupResources(CF, taskDef) {
|
static async cleanupResources(CF, taskDef) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue