Prefer shouldReadLogs for bool
parent
f7b7752040
commit
34dc192a62
|
|
@ -1282,17 +1282,17 @@ class AWSTaskRunner {
|
|||
cloud_runner_logger_1.default.log(`Cloud runner job status is ${(_a = (yield AWSTaskRunner.describeTasks(ECS, clusterName, taskArn))) === null || _a === void 0 ? void 0 : _a.lastStatus}`);
|
||||
const logBaseUrl = `https://${__1.Input.region}.console.aws.amazon.com/cloudwatch/home?region=${AWS.config.region}#logsV2:log-groups/log-group/${taskDef.taskDefStackName}`;
|
||||
cloud_runner_logger_1.default.log(`You can also see the logs at AWS Cloud Watch: ${logBaseUrl}`);
|
||||
let readingLogs = true;
|
||||
let shouldReadLogs = true;
|
||||
let timestamp = 0;
|
||||
while (readingLogs) {
|
||||
while (shouldReadLogs) {
|
||||
yield new Promise((resolve) => setTimeout(resolve, 1500));
|
||||
const taskData = yield AWSTaskRunner.describeTasks(ECS, clusterName, taskArn);
|
||||
({ timestamp, readingLogs } = AWSTaskRunner.checkStreamingShouldContinue(taskData, timestamp, readingLogs));
|
||||
({ iterator, readingLogs } = yield AWSTaskRunner.handleLogStreamIteration(kinesis, iterator, readingLogs, taskDef));
|
||||
({ timestamp, shouldReadLogs } = AWSTaskRunner.checkStreamingShouldContinue(taskData, timestamp, shouldReadLogs));
|
||||
({ iterator, shouldReadLogs } = yield AWSTaskRunner.handleLogStreamIteration(kinesis, iterator, shouldReadLogs, taskDef));
|
||||
}
|
||||
});
|
||||
}
|
||||
static handleLogStreamIteration(kinesis, iterator, readingLogs, taskDef) {
|
||||
static handleLogStreamIteration(kinesis, iterator, shouldReadLogs, taskDef) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const records = yield kinesis
|
||||
.getRecords({
|
||||
|
|
@ -1300,11 +1300,11 @@ class AWSTaskRunner {
|
|||
})
|
||||
.promise();
|
||||
iterator = records.NextShardIterator || '';
|
||||
readingLogs = AWSTaskRunner.logRecords(records, iterator, taskDef, readingLogs);
|
||||
return { iterator, readingLogs };
|
||||
shouldReadLogs = AWSTaskRunner.logRecords(records, iterator, taskDef, shouldReadLogs);
|
||||
return { iterator, shouldReadLogs };
|
||||
});
|
||||
}
|
||||
static checkStreamingShouldContinue(taskData, timestamp, readingLogs) {
|
||||
static checkStreamingShouldContinue(taskData, timestamp, shouldReadLogs) {
|
||||
if ((taskData === null || taskData === void 0 ? void 0 : taskData.lastStatus) !== 'RUNNING') {
|
||||
if (timestamp === 0) {
|
||||
cloud_runner_logger_1.default.log('## Cloud runner job stopped, streaming end of logs');
|
||||
|
|
@ -1312,13 +1312,13 @@ class AWSTaskRunner {
|
|||
}
|
||||
if (timestamp !== 0 && Date.now() - timestamp > 30000) {
|
||||
cloud_runner_logger_1.default.log('## Cloud runner status is not RUNNING for 30 seconds, last query for logs');
|
||||
readingLogs = false;
|
||||
shouldReadLogs = false;
|
||||
}
|
||||
cloud_runner_logger_1.default.log(`## Status of job: ${taskData.lastStatus}`);
|
||||
}
|
||||
return { timestamp, readingLogs };
|
||||
return { timestamp, shouldReadLogs };
|
||||
}
|
||||
static logRecords(records, iterator, taskDef, readingLogs) {
|
||||
static logRecords(records, iterator, taskDef, shouldReadLogs) {
|
||||
if (records.Records.length > 0 && iterator) {
|
||||
for (let index = 0; index < records.Records.length; index++) {
|
||||
const json = JSON.parse(zlib.gunzipSync(Buffer.from(records.Records[index].Data, 'base64')).toString('utf8'));
|
||||
|
|
@ -1327,7 +1327,7 @@ class AWSTaskRunner {
|
|||
let message = json.logEvents[logEventsIndex].message;
|
||||
if (json.logEvents[logEventsIndex].message.includes(taskDef.logid)) {
|
||||
cloud_runner_logger_1.default.log('End of log transmission received');
|
||||
readingLogs = false;
|
||||
shouldReadLogs = false;
|
||||
}
|
||||
else if (message.includes('Rebuilding Library because the asset database could not be found!')) {
|
||||
core.warning('LIBRARY NOT FOUND!');
|
||||
|
|
@ -1341,7 +1341,7 @@ class AWSTaskRunner {
|
|||
}
|
||||
}
|
||||
}
|
||||
return readingLogs;
|
||||
return shouldReadLogs;
|
||||
}
|
||||
static getLogStream(kinesis, kinesisStreamName) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -118,16 +118,16 @@ class AWSTaskRunner {
|
|||
|
||||
const logBaseUrl = `https://${Input.region}.console.aws.amazon.com/cloudwatch/home?region=${AWS.config.region}#logsV2:log-groups/log-group/${taskDef.taskDefStackName}`;
|
||||
CloudRunnerLogger.log(`You can also see the logs at AWS Cloud Watch: ${logBaseUrl}`);
|
||||
let readingLogs = true;
|
||||
let shouldReadLogs = true;
|
||||
let timestamp: number = 0;
|
||||
while (readingLogs) {
|
||||
while (shouldReadLogs) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 1500));
|
||||
const taskData = await AWSTaskRunner.describeTasks(ECS, clusterName, taskArn);
|
||||
({ timestamp, readingLogs } = AWSTaskRunner.checkStreamingShouldContinue(taskData, timestamp, readingLogs));
|
||||
({ iterator, readingLogs } = await AWSTaskRunner.handleLogStreamIteration(
|
||||
({ timestamp, shouldReadLogs } = AWSTaskRunner.checkStreamingShouldContinue(taskData, timestamp, shouldReadLogs));
|
||||
({ iterator, shouldReadLogs } = await AWSTaskRunner.handleLogStreamIteration(
|
||||
kinesis,
|
||||
iterator,
|
||||
readingLogs,
|
||||
shouldReadLogs,
|
||||
taskDef,
|
||||
));
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ class AWSTaskRunner {
|
|||
private static async handleLogStreamIteration(
|
||||
kinesis: AWS.Kinesis,
|
||||
iterator: string,
|
||||
readingLogs: boolean,
|
||||
shouldReadLogs: boolean,
|
||||
taskDef: CloudRunnerTaskDef,
|
||||
) {
|
||||
const records = await kinesis
|
||||
|
|
@ -145,11 +145,11 @@ class AWSTaskRunner {
|
|||
})
|
||||
.promise();
|
||||
iterator = records.NextShardIterator || '';
|
||||
readingLogs = AWSTaskRunner.logRecords(records, iterator, taskDef, readingLogs);
|
||||
return { iterator, readingLogs };
|
||||
shouldReadLogs = AWSTaskRunner.logRecords(records, iterator, taskDef, shouldReadLogs);
|
||||
return { iterator, shouldReadLogs };
|
||||
}
|
||||
|
||||
private static checkStreamingShouldContinue(taskData: AWS.ECS.Task, timestamp: number, readingLogs: boolean) {
|
||||
private static checkStreamingShouldContinue(taskData: AWS.ECS.Task, timestamp: number, shouldReadLogs: boolean) {
|
||||
if (taskData?.lastStatus !== 'RUNNING') {
|
||||
if (timestamp === 0) {
|
||||
CloudRunnerLogger.log('## Cloud runner job stopped, streaming end of logs');
|
||||
|
|
@ -157,14 +157,14 @@ class AWSTaskRunner {
|
|||
}
|
||||
if (timestamp !== 0 && Date.now() - timestamp > 30000) {
|
||||
CloudRunnerLogger.log('## Cloud runner status is not RUNNING for 30 seconds, last query for logs');
|
||||
readingLogs = false;
|
||||
shouldReadLogs = false;
|
||||
}
|
||||
CloudRunnerLogger.log(`## Status of job: ${taskData.lastStatus}`);
|
||||
}
|
||||
return { timestamp, readingLogs };
|
||||
return { timestamp, shouldReadLogs };
|
||||
}
|
||||
|
||||
private static logRecords(records, iterator: string, taskDef: CloudRunnerTaskDef, readingLogs: boolean) {
|
||||
private static logRecords(records, iterator: string, taskDef: CloudRunnerTaskDef, shouldReadLogs: boolean) {
|
||||
if (records.Records.length > 0 && iterator) {
|
||||
for (let index = 0; index < records.Records.length; index++) {
|
||||
const json = JSON.parse(
|
||||
|
|
@ -175,7 +175,7 @@ class AWSTaskRunner {
|
|||
let message = json.logEvents[logEventsIndex].message;
|
||||
if (json.logEvents[logEventsIndex].message.includes(taskDef.logid)) {
|
||||
CloudRunnerLogger.log('End of log transmission received');
|
||||
readingLogs = false;
|
||||
shouldReadLogs = false;
|
||||
} else if (message.includes('Rebuilding Library because the asset database could not be found!')) {
|
||||
core.warning('LIBRARY NOT FOUND!');
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ class AWSTaskRunner {
|
|||
}
|
||||
}
|
||||
}
|
||||
return readingLogs;
|
||||
return shouldReadLogs;
|
||||
}
|
||||
|
||||
private static async getLogStream(kinesis: AWS.Kinesis, kinesisStreamName: string) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue