Include log chunk when task runner sees log update, clarify if we can pull logs from same line or next line
parent
f563b8c810
commit
534c94e159
|
@ -3964,13 +3964,13 @@ class KubernetesTaskRunner {
|
||||||
cloud_runner_logger_1.default.log(`Log Start found in logs`);
|
cloud_runner_logger_1.default.log(`Log Start found in logs`);
|
||||||
}
|
}
|
||||||
if (chunk.includes(`LOGHASH:`)) {
|
if (chunk.includes(`LOGHASH:`)) {
|
||||||
remote_client_logger_1.RemoteClientLogger.HandleLogChunkLine(chunk);
|
remote_client_logger_1.RemoteClientLogger.HandleLogHash(chunk);
|
||||||
cloud_runner_logger_1.default.log(`Loghash found`);
|
cloud_runner_logger_1.default.log(`Loghash found`);
|
||||||
}
|
}
|
||||||
if (chunk.includes(`LOGS:`)) {
|
if (chunk.includes(`LOGS:`)) {
|
||||||
// remove "LOGS: " and decode base64 remaining
|
// remove "LOGS: " and decode base64 remaining
|
||||||
const unpacked = Buffer.from(chunk.split(`LOGS: `)[1], 'base64').toString('ascii');
|
const unpacked = Buffer.from(chunk.split(`LOGS: `)[1], 'base64').toString('ascii');
|
||||||
const result = remote_client_logger_1.RemoteClientLogger.HandleLogChunkLine(unpacked);
|
const result = remote_client_logger_1.RemoteClientLogger.HandleLogFull(unpacked);
|
||||||
cloud_runner_logger_1.default.log(`Logs found HandleLogChunkLineResult:${result}`);
|
cloud_runner_logger_1.default.log(`Logs found HandleLogChunkLineResult:${result}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3994,8 +3994,13 @@ class KubernetesTaskRunner {
|
||||||
const splitLogs = logs.split(`\n`);
|
const splitLogs = logs.split(`\n`);
|
||||||
for (const chunk of splitLogs) {
|
for (const chunk of splitLogs) {
|
||||||
const message = cloud_runner_1.default.buildParameters.cloudRunnerDebug ? chunk : chunk.split(`Z `)[1];
|
const message = cloud_runner_1.default.buildParameters.cloudRunnerDebug ? chunk : chunk.split(`Z `)[1];
|
||||||
|
// if line contains "LOGS: " then stop
|
||||||
|
if (message.includes(`LOGS:`)) {
|
||||||
|
cloud_runner_logger_1.default.log(`LOGS: found`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
({ shouldReadLogs, shouldCleanup, output } = follow_log_stream_service_1.FollowLogStreamService.handleIteration(message, shouldReadLogs, shouldCleanup, output));
|
({ shouldReadLogs, shouldCleanup, output } = follow_log_stream_service_1.FollowLogStreamService.handleIteration(message, shouldReadLogs, shouldCleanup, output));
|
||||||
const result = remote_client_logger_1.RemoteClientLogger.HandleLogChunkLine(message);
|
const result = remote_client_logger_1.RemoteClientLogger.HandleLog(message);
|
||||||
if (result) {
|
if (result) {
|
||||||
follow_log_stream_service_1.FollowLogStreamService.DidReceiveEndOfTransmission = true;
|
follow_log_stream_service_1.FollowLogStreamService.DidReceiveEndOfTransmission = true;
|
||||||
}
|
}
|
||||||
|
@ -4632,10 +4637,9 @@ class RemoteClientLogger {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 15000));
|
await new Promise((resolve) => setTimeout(resolve, 15000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static HandleLogChunkLine(message) {
|
static HandleLog(message) {
|
||||||
if (message.includes('LOGHASH: ')) {
|
if (message.includes('LOGHASH: ')) {
|
||||||
RemoteClientLogger.md5 = message.split(`LOGHASH: `)[1];
|
RemoteClientLogger.HandleLogHash(message);
|
||||||
cloud_runner_logger_1.default.log(`LOGHASH: ${RemoteClientLogger.md5}`);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (RemoteClientLogger.value !== '') {
|
if (RemoteClientLogger.value !== '') {
|
||||||
|
@ -4650,6 +4654,23 @@ class RemoteClientLogger {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
static HandleLogHash(message) {
|
||||||
|
if (message.includes('LOGHASH: ')) {
|
||||||
|
RemoteClientLogger.md5 = message.split(`LOGHASH: `)[1];
|
||||||
|
cloud_runner_logger_1.default.log(`LOGHASH: ${RemoteClientLogger.md5}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error(`LOGHASH: not found`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static HandleLogFull(message) {
|
||||||
|
const hashedValue = md5(message);
|
||||||
|
if (RemoteClientLogger.md5 === hashedValue) {
|
||||||
|
cloud_runner_logger_1.default.log(`LOG COMPLETE`);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.RemoteClientLogger = RemoteClientLogger;
|
exports.RemoteClientLogger = RemoteClientLogger;
|
||||||
RemoteClientLogger.value = '';
|
RemoteClientLogger.value = '';
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -43,13 +43,13 @@ class KubernetesTaskRunner {
|
||||||
CloudRunnerLogger.log(`Log Start found in logs`);
|
CloudRunnerLogger.log(`Log Start found in logs`);
|
||||||
}
|
}
|
||||||
if (chunk.includes(`LOGHASH:`)) {
|
if (chunk.includes(`LOGHASH:`)) {
|
||||||
RemoteClientLogger.HandleLogChunkLine(chunk);
|
RemoteClientLogger.HandleLogHash(chunk);
|
||||||
CloudRunnerLogger.log(`Loghash found`);
|
CloudRunnerLogger.log(`Loghash found`);
|
||||||
}
|
}
|
||||||
if (chunk.includes(`LOGS:`)) {
|
if (chunk.includes(`LOGS:`)) {
|
||||||
// remove "LOGS: " and decode base64 remaining
|
// remove "LOGS: " and decode base64 remaining
|
||||||
const unpacked = Buffer.from(chunk.split(`LOGS: `)[1], 'base64').toString('ascii');
|
const unpacked = Buffer.from(chunk.split(`LOGS: `)[1], 'base64').toString('ascii');
|
||||||
const result = RemoteClientLogger.HandleLogChunkLine(unpacked);
|
const result = RemoteClientLogger.HandleLogFull(unpacked);
|
||||||
CloudRunnerLogger.log(`Logs found HandleLogChunkLineResult:${result}`);
|
CloudRunnerLogger.log(`Logs found HandleLogChunkLineResult:${result}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,13 +73,19 @@ class KubernetesTaskRunner {
|
||||||
const splitLogs = logs.split(`\n`);
|
const splitLogs = logs.split(`\n`);
|
||||||
for (const chunk of splitLogs) {
|
for (const chunk of splitLogs) {
|
||||||
const message = CloudRunner.buildParameters.cloudRunnerDebug ? chunk : chunk.split(`Z `)[1];
|
const message = CloudRunner.buildParameters.cloudRunnerDebug ? chunk : chunk.split(`Z `)[1];
|
||||||
|
|
||||||
|
// if line contains "LOGS: " then stop
|
||||||
|
if (message.includes(`LOGS:`)) {
|
||||||
|
CloudRunnerLogger.log(`LOGS: found`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
({ shouldReadLogs, shouldCleanup, output } = FollowLogStreamService.handleIteration(
|
({ shouldReadLogs, shouldCleanup, output } = FollowLogStreamService.handleIteration(
|
||||||
message,
|
message,
|
||||||
shouldReadLogs,
|
shouldReadLogs,
|
||||||
shouldCleanup,
|
shouldCleanup,
|
||||||
output,
|
output,
|
||||||
));
|
));
|
||||||
const result = RemoteClientLogger.HandleLogChunkLine(message);
|
const result = RemoteClientLogger.HandleLog(message);
|
||||||
if (result) {
|
if (result) {
|
||||||
FollowLogStreamService.DidReceiveEndOfTransmission = true;
|
FollowLogStreamService.DidReceiveEndOfTransmission = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,10 +68,9 @@ export class RemoteClientLogger {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 15000));
|
await new Promise((resolve) => setTimeout(resolve, 15000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static HandleLogChunkLine(message: string): boolean {
|
public static HandleLog(message: string): boolean {
|
||||||
if (message.includes('LOGHASH: ')) {
|
if (message.includes('LOGHASH: ')) {
|
||||||
RemoteClientLogger.md5 = message.split(`LOGHASH: `)[1];
|
RemoteClientLogger.HandleLogHash(message);
|
||||||
CloudRunnerLogger.log(`LOGHASH: ${RemoteClientLogger.md5}`);
|
|
||||||
} else {
|
} else {
|
||||||
if (RemoteClientLogger.value !== '') {
|
if (RemoteClientLogger.value !== '') {
|
||||||
RemoteClientLogger.value += `\n`;
|
RemoteClientLogger.value += `\n`;
|
||||||
|
@ -88,6 +87,24 @@ export class RemoteClientLogger {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
public static HandleLogHash(message: string) {
|
||||||
|
if (message.includes('LOGHASH: ')) {
|
||||||
|
RemoteClientLogger.md5 = message.split(`LOGHASH: `)[1];
|
||||||
|
CloudRunnerLogger.log(`LOGHASH: ${RemoteClientLogger.md5}`);
|
||||||
|
} else {
|
||||||
|
throw new Error(`LOGHASH: not found`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static HandleLogFull(message: string): boolean {
|
||||||
|
const hashedValue = md5(message);
|
||||||
|
if (RemoteClientLogger.md5 === hashedValue) {
|
||||||
|
CloudRunnerLogger.log(`LOG COMPLETE`);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
static value: string = '';
|
static value: string = '';
|
||||||
static md5: any;
|
static md5: any;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@ describe('Cloud Runner Remote Client', () => {
|
||||||
const testLogStream = 'Test \n Log \n Stream';
|
const testLogStream = 'Test \n Log \n Stream';
|
||||||
|
|
||||||
const splitLogStream = testLogStream.split('\n');
|
const splitLogStream = testLogStream.split('\n');
|
||||||
RemoteClientLogger.HandleLogChunkLine(`LOGHASH: ${md5(testLogStream)}`);
|
RemoteClientLogger.HandleLog(`LOGHASH: ${md5(testLogStream)}`);
|
||||||
let completed = false;
|
let completed = false;
|
||||||
for (const element of splitLogStream) {
|
for (const element of splitLogStream) {
|
||||||
completed = RemoteClientLogger.HandleLogChunkLine(element);
|
completed = RemoteClientLogger.HandleLog(element);
|
||||||
}
|
}
|
||||||
expect(completed).toBeTruthy();
|
expect(completed).toBeTruthy();
|
||||||
}, 1_000_000_000);
|
}, 1_000_000_000);
|
||||||
|
|
Loading…
Reference in New Issue