Logging improvement

pull/273/head
Frostebite 2021-06-19 05:07:18 +01:00
parent 23e042fcbe
commit 6dbb6e8ccb
3 changed files with 15 additions and 24 deletions

17
dist/index.js vendored
View File

@ -1539,7 +1539,7 @@ class Kubernetes {
core.info('Job created');
yield kubernetes_storage_1.default.watchUntilPVCNotPending(this.kubeClient, this.pvcName, this.namespace);
core.info('PVC Bound');
this.setPodNameAndContainerName(yield this.getPod());
this.setPodNameAndContainerName(yield this.findPod());
core.info('Watching pod until running');
yield this.watchUntilPodRunning();
core.info('Pod running, streaming logs');
@ -1553,18 +1553,13 @@ class Kubernetes {
}
});
}
getPod() {
findPod() {
return __awaiter(this, void 0, void 0, function* () {
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; });
if (pod === undefined) {
throw new Error("pod with job-name label doesn't exist");
}
return pod;
}
else {
return (yield this.kubeClient.readNamespacedPod(this.podName, this.namespace)).body;
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; });
if (pod === undefined) {
throw new Error("pod with job-name label doesn't exist");
}
return pod;
});
}
runCloneJob() {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -320,7 +320,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
core.info('Job created');
await KubernetesStorage.watchUntilPVCNotPending(this.kubeClient, this.pvcName, this.namespace);
core.info('PVC Bound');
this.setPodNameAndContainerName(await this.getPod());
this.setPodNameAndContainerName(await this.findPod());
core.info('Watching pod until running');
await this.watchUntilPodRunning();
core.info('Pod running, streaming logs');
@ -333,18 +333,14 @@ class Kubernetes implements RemoteBuilderProviderInterface {
}
}
async getPod() {
if (this.podName === '') {
const pod = (await this.kubeClient.listNamespacedPod(this.namespace)).body.items.find(
(x) => x.metadata?.labels?.['job-name'] === this.jobName,
);
if (pod === undefined) {
throw new Error("pod with job-name label doesn't exist");
}
return pod;
} else {
return (await this.kubeClient.readNamespacedPod(this.podName, this.namespace)).body;
async findPod() {
const pod = (await this.kubeClient.listNamespacedPod(this.namespace)).body.items.find(
(x) => x.metadata?.labels?.['job-name'] === this.jobName,
);
if (pod === undefined) {
throw new Error("pod with job-name label doesn't exist");
}
return pod;
}
async runCloneJob() {