K8s support for test logging

pull/310/head
Frostebite 2021-12-24 02:39:00 +00:00
parent 2e5b4ae497
commit 7f75c6c75b
3 changed files with 12 additions and 2 deletions

5
dist/index.js vendored
View File

@ -1588,6 +1588,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const client_node_1 = __webpack_require__(89679); const client_node_1 = __webpack_require__(89679);
const stream_1 = __webpack_require__(92413); const stream_1 = __webpack_require__(92413);
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855)); const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
const cloud_runner_state_1 = __webpack_require__(70912);
const fs_1 = __importDefault(__webpack_require__(35747));
class KubernetesLogging { class KubernetesLogging {
static streamLogs(kubeConfig, kubeClient, jobName, podName, containerName, namespace, logCallback) { static streamLogs(kubeConfig, kubeClient, jobName, podName, containerName, namespace, logCallback) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -1596,6 +1598,9 @@ class KubernetesLogging {
let didStreamAnyLogs = false; let didStreamAnyLogs = false;
stream._write = (chunk, encoding, next) => { stream._write = (chunk, encoding, next) => {
didStreamAnyLogs = true; didStreamAnyLogs = true;
if (cloud_runner_state_1.CloudRunnerState.buildParams.logToFile) {
fs_1.default.appendFileSync(`${cloud_runner_state_1.CloudRunnerState.buildGuid}-outputfile.txt`, `${chunk.toString()}\r\n`);
}
logCallback(chunk.toString()); logCallback(chunk.toString());
next(); next();
}; };

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,8 @@
import { CoreV1Api, KubeConfig, Log } from '@kubernetes/client-node'; import { CoreV1Api, KubeConfig, Log } from '@kubernetes/client-node';
import { Writable } from 'stream'; import { Writable } from 'stream';
import CloudRunnerLogger from '../services/cloud-runner-logger'; import CloudRunnerLogger from '../services/cloud-runner-logger';
import { CloudRunnerState } from '../state/cloud-runner-state';
import fs from 'fs';
class KubernetesLogging { class KubernetesLogging {
static async streamLogs( static async streamLogs(
kubeConfig: KubeConfig, kubeConfig: KubeConfig,
@ -17,6 +18,10 @@ class KubernetesLogging {
let didStreamAnyLogs: boolean = false; let didStreamAnyLogs: boolean = false;
stream._write = (chunk, encoding, next) => { stream._write = (chunk, encoding, next) => {
didStreamAnyLogs = true; didStreamAnyLogs = true;
if (CloudRunnerState.buildParams.logToFile) {
fs.appendFileSync(`${CloudRunnerState.buildGuid}-outputfile.txt`, `${chunk.toString()}\r\n`);
}
logCallback(chunk.toString()); logCallback(chunk.toString());
next(); next();
}; };