Log json stringify error
parent
e22cd3306e
commit
aa2579095b
|
|
@ -737,6 +737,8 @@ const base64 = __webpack_require__(85848);
|
||||||
const pollInterval = 20000;
|
const pollInterval = 20000;
|
||||||
class Kubernetes {
|
class Kubernetes {
|
||||||
constructor(buildParameters, baseImage) {
|
constructor(buildParameters, baseImage) {
|
||||||
|
this.podName = '';
|
||||||
|
this.containerName = '';
|
||||||
const kc = new k8s.KubeConfig();
|
const kc = new k8s.KubeConfig();
|
||||||
kc.loadFromDefault();
|
kc.loadFromDefault();
|
||||||
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
|
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
|
||||||
|
|
@ -768,12 +770,18 @@ class Kubernetes {
|
||||||
ParameterValue: this.buildParameters.githubToken,
|
ParameterValue: this.buildParameters.githubToken,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
// setup
|
try {
|
||||||
yield this.createSecret(defaultSecretsArray);
|
// setup
|
||||||
yield this.createPersistentVolumeClaim();
|
yield this.createSecret(defaultSecretsArray);
|
||||||
// run
|
yield this.createPersistentVolumeClaim();
|
||||||
yield this.runCloneJob();
|
// run
|
||||||
yield this.runBuildJob();
|
yield this.runCloneJob();
|
||||||
|
yield this.runBuildJob();
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
core.info(JSON.stringify(error, undefined, 4));
|
||||||
|
core.error(error);
|
||||||
|
}
|
||||||
core.setOutput('volume', this.pvcName);
|
core.setOutput('volume', this.pvcName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -975,7 +983,7 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
getPod() {
|
getPod() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
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; });
|
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;
|
return pod;
|
||||||
}
|
}
|
||||||
|
|
@ -1065,13 +1073,13 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
streamLogs() {
|
streamLogs() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
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 {
|
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, {
|
yield new Promise((resolve) => new client_node_1.Log(this.kubeConfig).log(this.namespace, this.podName, this.containerName, stream, resolve, {
|
||||||
follow: true,
|
follow: true,
|
||||||
pretty: true,
|
pretty: true,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -19,9 +19,9 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
private pvcName: string;
|
private pvcName: string;
|
||||||
private secretName: string;
|
private secretName: string;
|
||||||
private jobName: string;
|
private jobName: string;
|
||||||
private podName: string | any;
|
|
||||||
private containerName: string | any;
|
|
||||||
private namespace: string;
|
private namespace: string;
|
||||||
|
private podName: string = '';
|
||||||
|
private containerName: string = '';
|
||||||
|
|
||||||
constructor(buildParameters: BuildParameters, baseImage) {
|
constructor(buildParameters: BuildParameters, baseImage) {
|
||||||
const kc = new k8s.KubeConfig();
|
const kc = new k8s.KubeConfig();
|
||||||
|
|
@ -57,13 +57,17 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
ParameterValue: this.buildParameters.githubToken,
|
ParameterValue: this.buildParameters.githubToken,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
// setup
|
try {
|
||||||
await this.createSecret(defaultSecretsArray);
|
// setup
|
||||||
await this.createPersistentVolumeClaim();
|
await this.createSecret(defaultSecretsArray);
|
||||||
|
await this.createPersistentVolumeClaim();
|
||||||
// run
|
// run
|
||||||
await this.runCloneJob();
|
await this.runCloneJob();
|
||||||
await this.runBuildJob();
|
await this.runBuildJob();
|
||||||
|
} catch (error) {
|
||||||
|
core.info(JSON.stringify(error, undefined, 4));
|
||||||
|
core.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
core.setOutput('volume', this.pvcName);
|
core.setOutput('volume', this.pvcName);
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +269,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPod() {
|
async getPod() {
|
||||||
if (this.podName === undefined) {
|
if (this.podName === '') {
|
||||||
const pod = (await this.kubeClient.listNamespacedPod(this.namespace)).body.items.find(
|
const pod = (await this.kubeClient.listNamespacedPod(this.namespace)).body.items.find(
|
||||||
(x) => x.metadata?.labels?.['job-name'] === this.jobName,
|
(x) => x.metadata?.labels?.['job-name'] === this.jobName,
|
||||||
);
|
);
|
||||||
|
|
@ -356,15 +360,13 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
async streamLogs() {
|
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 {
|
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) =>
|
await new Promise((resolve) =>
|
||||||
new Log(this.kubeConfig).log(this.namespace, this.podName, this.containerName, stream, resolve, {
|
new Log(this.kubeConfig).log(this.namespace, this.podName, this.containerName, stream, resolve, {
|
||||||
follow: true,
|
follow: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue