This commit is contained in:
Frostebite 2024-01-30 22:28:53 +00:00
parent e038adc834
commit 44e887fae0
7 changed files with 3 additions and 83 deletions

View File

@ -42,7 +42,6 @@ jobs:
- 'cloud-runner-end2end-locking' - 'cloud-runner-end2end-locking'
- 'cloud-runner-end2end-caching' - 'cloud-runner-end2end-caching'
- 'cloud-runner-end2end-retaining' - 'cloud-runner-end2end-retaining'
- 'cloud-runner-remote-client'
- 'cloud-runner-caching' - 'cloud-runner-caching'
- 'cloud-runner-environment' - 'cloud-runner-environment'
- 'cloud-runner-image' - 'cloud-runner-image'

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

BIN
dist/licenses.txt generated vendored

Binary file not shown.

View File

@ -5,7 +5,6 @@ import { CloudRunnerSystem } from '../../services/core/cloud-runner-system';
import CloudRunner from '../../cloud-runner'; import CloudRunner from '../../cloud-runner';
import KubernetesPods from './kubernetes-pods'; import KubernetesPods from './kubernetes-pods';
import { FollowLogStreamService } from '../../services/core/follow-log-stream-service'; import { FollowLogStreamService } from '../../services/core/follow-log-stream-service';
import { RemoteClientLogger } from '../../remote-client/remote-client-logger';
class KubernetesTaskRunner { class KubernetesTaskRunner {
static readonly maxRetry: number = 3; static readonly maxRetry: number = 3;
@ -39,27 +38,6 @@ class KubernetesTaskRunner {
// split output chunk and handle per line // split output chunk and handle per line
for (const chunk of outputChunk.split(`\n`)) { for (const chunk of outputChunk.split(`\n`)) {
// check if log start included in logs if so log a message
if (chunk.includes(`Collected Logs`)) {
CloudRunnerLogger.log(`Log Start found in logs`);
}
if (chunk.includes(`LOGHASH:`)) {
RemoteClientLogger.HandleLogHash(chunk);
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( ({ shouldReadLogs, shouldCleanup, output } = FollowLogStreamService.handleIteration(
chunk, chunk,
shouldReadLogs, shouldReadLogs,

View File

@ -3,7 +3,6 @@ import fs from 'node:fs';
import path from 'node:path'; import path from 'node:path';
import CloudRunner from '../cloud-runner'; import CloudRunner from '../cloud-runner';
import CloudRunnerOptions from '../options/cloud-runner-options'; import CloudRunnerOptions from '../options/cloud-runner-options';
import * as md5 from 'ts-md5';
export class RemoteClientLogger { export class RemoteClientLogger {
private static get LogFilePath() { private static get LogFilePath() {
@ -71,44 +70,13 @@ export class RemoteClientLogger {
// } // }
} }
public static HandleLog(message: string): boolean { public static HandleLog(message: string): boolean {
if (message.includes('LOGHASH: ')) {
RemoteClientLogger.HandleLogHash(message);
} else {
if (RemoteClientLogger.value !== '') { if (RemoteClientLogger.value !== '') {
RemoteClientLogger.value += `\n`; RemoteClientLogger.value += `\n`;
} }
RemoteClientLogger.value += message; RemoteClientLogger.value += message;
const hashedValue = md5.Md5.hashStr(RemoteClientLogger.value);
if (RemoteClientLogger.md5 === hashedValue) {
CloudRunnerLogger.log(`LOG COMPLETE`);
return true;
}
}
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.Md5.hashStr(message);
if (RemoteClientLogger.md5 === hashedValue) {
CloudRunnerLogger.log(`LOG COMPLETE`);
return true;
} else {
CloudRunnerLogger.log(`LOG INCOMPLETE ${RemoteClientLogger.md5} ${hashedValue}`);
}
return false; return false;
} }
static value: string = ''; static value: string = '';
static md5: any;
} }

View File

@ -1,25 +0,0 @@
import { RemoteClientLogger } from '../../remote-client/remote-client-logger';
import setups from '../cloud-runner-suite.test';
const md5 = require('md5');
describe('Cloud Runner Remote Client', () => {
it('Responds', () => {});
setups();
it('Loghash digestion input matches output', async () => {
const testLogStream = 'Test \n Log \n Stream';
const splitLogStream = testLogStream.split('\n');
RemoteClientLogger.HandleLog(`LOGHASH: ${md5(testLogStream)}`);
let completed = false;
for (const element of splitLogStream) {
completed = RemoteClientLogger.HandleLog(element);
}
expect(completed).toBeTruthy();
}, 1_000_000_000);
// eslint-disable-next-line unicorn/consistent-function-scoping, no-unused-vars
function CreateLogWatcher(callback: (finalMessage: string) => void) {
return (message: string) => {
callback(message);
};
}
});