Using Log class from k8s client to stream
parent
0d1f360db7
commit
b3dee76d5a
|
|
@ -731,6 +731,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const k8s = __importStar(__webpack_require__(89679));
|
||||
const core = __importStar(__webpack_require__(42186));
|
||||
const client_node_1 = __webpack_require__(89679);
|
||||
const stream_1 = __webpack_require__(92413);
|
||||
const base64 = __webpack_require__(85848);
|
||||
const pollInterval = 20000;
|
||||
class Kubernetes {
|
||||
|
|
@ -747,6 +749,7 @@ class Kubernetes {
|
|||
const secretName = `build-credentials-${buildId}`;
|
||||
const jobName = `unity-builder-job-${buildId}`;
|
||||
const namespace = 'default';
|
||||
this.kubeConfig = kc;
|
||||
this.kubeClient = k8sApi;
|
||||
this.kubeClientBatch = k8sBatchApi;
|
||||
this.buildId = buildId;
|
||||
|
|
@ -1048,12 +1051,12 @@ class Kubernetes {
|
|||
running = ((_a = pod.body.status) === null || _a === void 0 ? void 0 : _a.phase) === 'Running';
|
||||
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
||||
core.info('Polling logs...');
|
||||
const logs = yield this.kubeClient.readNamespacedPodLog(name, namespace, container, true, undefined, undefined, undefined, undefined, undefined, undefined, true);
|
||||
logs.response.on('data', (data) => {
|
||||
core.info('LOGS RECEIVED');
|
||||
core.info(data);
|
||||
});
|
||||
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
||||
const stream = new stream_1.Writable();
|
||||
stream._write = (chunk, encoding, next) => {
|
||||
core.info(chunk.toString());
|
||||
next();
|
||||
};
|
||||
yield new Promise((resolve) => new client_node_1.Log(this.kubeConfig).log(namespace, name, container, stream, resolve));
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,11 +1,14 @@
|
|||
import * as k8s from '@kubernetes/client-node';
|
||||
import { BuildParameters } from '.';
|
||||
import * as core from '@actions/core';
|
||||
import { KubeConfig, Log } from '@kubernetes/client-node';
|
||||
import { Writable } from 'stream';
|
||||
const base64 = require('base-64');
|
||||
|
||||
const pollInterval = 20000;
|
||||
|
||||
class Kubernetes {
|
||||
private static kubeConfig: KubeConfig;
|
||||
private static kubeClient: k8s.CoreV1Api;
|
||||
private static kubeClientBatch: k8s.BatchV1Api;
|
||||
private static buildId: string;
|
||||
|
|
@ -32,6 +35,7 @@ class Kubernetes {
|
|||
const jobName = `unity-builder-job-${buildId}`;
|
||||
const namespace = 'default';
|
||||
|
||||
this.kubeConfig = kc;
|
||||
this.kubeClient = k8sApi;
|
||||
this.kubeClientBatch = k8sBatchApi;
|
||||
this.buildId = buildId;
|
||||
|
|
@ -336,24 +340,12 @@ class Kubernetes {
|
|||
running = pod.body.status?.phase === 'Running';
|
||||
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
||||
core.info('Polling logs...');
|
||||
const logs = await this.kubeClient.readNamespacedPodLog(
|
||||
name,
|
||||
namespace,
|
||||
container,
|
||||
true,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
logs.response.on('data', (data) => {
|
||||
core.info('LOGS RECEIVED');
|
||||
core.info(data);
|
||||
});
|
||||
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
||||
const stream = new Writable();
|
||||
stream._write = (chunk, encoding, next) => {
|
||||
core.info(chunk.toString());
|
||||
next();
|
||||
};
|
||||
await new Promise((resolve) => new Log(this.kubeConfig).log(namespace, name, container, stream, resolve));
|
||||
}
|
||||
} catch (error) {
|
||||
core.error(JSON.stringify(error, undefined, 4));
|
||||
|
|
|
|||
Loading…
Reference in New Issue