mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-07 20:35:33 -04:00
Interrupt k8s logs when logs found
This commit is contained in:
parent
9cb82940fb
commit
4b072164b5
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
@ -32,7 +32,6 @@ class KubernetesTaskRunner {
|
||||
? ` -f -c ${containerName}`
|
||||
: ` --previous`;
|
||||
|
||||
let logs;
|
||||
const callback = (outputChunk: string) => {
|
||||
output += outputChunk;
|
||||
|
||||
@ -47,15 +46,28 @@ class KubernetesTaskRunner {
|
||||
CloudRunnerLogger.log(`Loghash found`);
|
||||
}
|
||||
if (chunk.includes(`LOGS:`)) {
|
||||
CloudRunnerLogger.log(`LOGS: found`);
|
||||
|
||||
// remove "LOGS: " and decode base64 remaining
|
||||
const unpacked = Buffer.from(chunk.split(`LOGS: `)[1], 'base64').toString('ascii');
|
||||
const result = RemoteClientLogger.HandleLogFull(unpacked);
|
||||
CloudRunnerLogger.log(`Logs found HandleLogChunkLineResult:${result}`);
|
||||
if (result) {
|
||||
FollowLogStreamService.DidReceiveEndOfTransmission = true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
({ shouldReadLogs, shouldCleanup, output } = FollowLogStreamService.handleIteration(
|
||||
chunk,
|
||||
shouldReadLogs,
|
||||
shouldCleanup,
|
||||
output,
|
||||
));
|
||||
}
|
||||
};
|
||||
try {
|
||||
logs = await CloudRunnerSystem.Run(`kubectl logs ${podName}${extraFlags}`, false, true, callback);
|
||||
await CloudRunnerSystem.Run(`kubectl logs ${podName}${extraFlags}`, false, true, callback);
|
||||
} catch (error: any) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 3000));
|
||||
const continueStreaming = await KubernetesPods.IsPodRunning(podName, namespace, kubeClient);
|
||||
@ -70,26 +82,6 @@ class KubernetesTaskRunner {
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
const splitLogs = logs.split(`\n`);
|
||||
for (const chunk of splitLogs) {
|
||||
const message = CloudRunner.buildParameters.cloudRunnerDebug ? chunk : chunk.split(`Z `)[1];
|
||||
|
||||
// if line contains "LOGS: " then stop
|
||||
if (message.includes(`LOGS:`)) {
|
||||
CloudRunnerLogger.log(`LOGS: found`);
|
||||
continue;
|
||||
}
|
||||
({ shouldReadLogs, shouldCleanup, output } = FollowLogStreamService.handleIteration(
|
||||
message,
|
||||
shouldReadLogs,
|
||||
shouldCleanup,
|
||||
output,
|
||||
));
|
||||
const result = RemoteClientLogger.HandleLog(message);
|
||||
if (result) {
|
||||
FollowLogStreamService.DidReceiveEndOfTransmission = true;
|
||||
}
|
||||
}
|
||||
if (FollowLogStreamService.DidReceiveEndOfTransmission) {
|
||||
CloudRunnerLogger.log('end of log stream');
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user