Log json stringify error

pull/273/head
Frostebite 2021-06-06 21:14:12 +01:00
parent e22cd3306e
commit aa2579095b
3 changed files with 42 additions and 32 deletions

34
dist/index.js vendored
View File

@ -737,6 +737,8 @@ const base64 = __webpack_require__(85848);
const pollInterval = 20000;
class Kubernetes {
constructor(buildParameters, baseImage) {
this.podName = '';
this.containerName = '';
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
@ -768,12 +770,18 @@ class Kubernetes {
ParameterValue: this.buildParameters.githubToken,
},
];
// setup
yield this.createSecret(defaultSecretsArray);
yield this.createPersistentVolumeClaim();
// run
yield this.runCloneJob();
yield this.runBuildJob();
try {
// setup
yield this.createSecret(defaultSecretsArray);
yield this.createPersistentVolumeClaim();
// run
yield this.runCloneJob();
yield this.runBuildJob();
}
catch (error) {
core.info(JSON.stringify(error, undefined, 4));
core.error(error);
}
core.setOutput('volume', this.pvcName);
});
}
@ -975,7 +983,7 @@ class Kubernetes {
}
getPod() {
return __awaiter(this, void 0, void 0, function* () {
if (this.podName === undefined) {
if (this.podName === '') {
const pod = (yield this.kubeClient.listNamespacedPod(this.namespace)).body.items.find((x) => { var _a, _b; return ((_b = (_a = x.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['job-name']) === this.jobName; });
return pod;
}
@ -1065,13 +1073,13 @@ class Kubernetes {
}
streamLogs() {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Streaming logs from pod: ${this.podName} container: ${this.containerName} namespace: ${this.namespace}`);
const stream = new stream_1.Writable();
stream._write = (chunk, encoding, next) => {
core.info(chunk.toString());
next();
};
try {
core.info(`Streaming logs from pod: ${this.podName} container: ${this.containerName} namespace: ${this.namespace}`);
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(this.namespace, this.podName, this.containerName, stream, resolve, {
follow: true,
pretty: true,

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -19,9 +19,9 @@ class Kubernetes implements RemoteBuilderProviderInterface {
private pvcName: string;
private secretName: string;
private jobName: string;
private podName: string | any;
private containerName: string | any;
private namespace: string;
private podName: string = '';
private containerName: string = '';
constructor(buildParameters: BuildParameters, baseImage) {
const kc = new k8s.KubeConfig();
@ -57,13 +57,17 @@ class Kubernetes implements RemoteBuilderProviderInterface {
ParameterValue: this.buildParameters.githubToken,
},
];
// setup
await this.createSecret(defaultSecretsArray);
await this.createPersistentVolumeClaim();
// run
await this.runCloneJob();
await this.runBuildJob();
try {
// setup
await this.createSecret(defaultSecretsArray);
await this.createPersistentVolumeClaim();
// run
await this.runCloneJob();
await this.runBuildJob();
} catch (error) {
core.info(JSON.stringify(error, undefined, 4));
core.error(error);
}
core.setOutput('volume', this.pvcName);
}
@ -265,7 +269,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
}
async getPod() {
if (this.podName === undefined) {
if (this.podName === '') {
const pod = (await this.kubeClient.listNamespacedPod(this.namespace)).body.items.find(
(x) => x.metadata?.labels?.['job-name'] === this.jobName,
);
@ -356,15 +360,13 @@ class Kubernetes implements RemoteBuilderProviderInterface {
}
async streamLogs() {
core.info(`Streaming logs from pod: ${this.podName} container: ${this.containerName} namespace: ${this.namespace}`);
const stream = new Writable();
stream._write = (chunk, encoding, next) => {
core.info(chunk.toString());
next();
};
try {
core.info(
`Streaming logs from pod: ${this.podName} container: ${this.containerName} namespace: ${this.namespace}`,
);
const stream = new Writable();
stream._write = (chunk, encoding, next) => {
core.info(chunk.toString());
next();
};
await new Promise((resolve) =>
new Log(this.kubeConfig).log(this.namespace, this.podName, this.containerName, stream, resolve, {
follow: true,