follow logs

pull/265/head
Frostebite 2021-05-23 21:02:39 +01:00
parent 968a9190d6
commit fd9e9d058a
4 changed files with 5909 additions and 65 deletions

40
dist/index.js vendored
View File

@ -1005,12 +1005,13 @@ class Kubernetes {
},
};
job.spec.backoffLimit = 1;
yield this.kubeClientBatch.createNamespacedJob(this.namespace, job);
const jobResults = yield this.kubeClientBatch.createNamespacedJob(this.namespace, job);
core.info(jobResults.body);
core.info('Job created');
});
}
static watchBuildJobUntilFinished() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
let podname;
let ready = false;
@ -1034,35 +1035,14 @@ class Kubernetes {
}
}
core.info(`Watching build job ${podname}`);
let logQueryTime;
let complete = false;
while (!complete) {
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
const podStatus = yield this.kubeClient.readNamespacedPod(podname, this.namespace);
if (((_f = (_e = podStatus.body) === null || _e === void 0 ? void 0 : _e.status) === null || _f === void 0 ? void 0 : _f.phase) !== 'Running') {
complete = true;
}
const logs = yield this.kubeClient.readNamespacedPodLog(podname, this.namespace, undefined, true);
if (logs.body !== undefined) {
const arrayOfLines = (_h = (_g = logs.body) === null || _g === void 0 ? void 0 : _g.match(/[^\n\r]+/g)) === null || _h === void 0 ? void 0 : _h.reverse();
if (!arrayOfLines) {
continue;
}
for (const element of arrayOfLines) {
const [time, ...line] = element.split(' ');
if (time !== logQueryTime) {
core.info(line.join(' '));
}
else {
break;
}
}
if (((_k = (_j = podStatus.body) === null || _j === void 0 ? void 0 : _j.status) === null || _k === void 0 ? void 0 : _k.phase) === 'Failed') {
throw new Error('Kubernetes job failed');
}
logQueryTime = arrayOfLines[0].split(' ')[0];
}
}
yield new Promise((resolve) => {
logs.response.on('data', (chunk) => {
core.info(chunk);
});
logs.response.on('close', resolve);
logs.response.on('end', resolve);
});
});
}
static cleanup() {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -291,7 +291,8 @@ class Kubernetes {
},
};
job.spec.backoffLimit = 1;
await this.kubeClientBatch.createNamespacedJob(this.namespace, job);
const jobResults = await this.kubeClientBatch.createNamespacedJob(this.namespace, job);
core.info(jobResults.body);
core.info('Job created');
}
@ -318,39 +319,15 @@ class Kubernetes {
}
core.info(`Watching build job ${podname}`);
let logQueryTime;
let complete = false;
while (!complete) {
await new Promise((resolve) => setTimeout(resolve, pollInterval));
const podStatus = await this.kubeClient.readNamespacedPod(podname, this.namespace);
if (podStatus.body?.status?.phase !== 'Running') {
complete = true;
}
const logs = await this.kubeClient.readNamespacedPodLog(podname, this.namespace, undefined, true);
if (logs.body !== undefined) {
const arrayOfLines = logs.body?.match(/[^\n\r]+/g)?.reverse();
if (!arrayOfLines) {
continue;
}
for (const element of arrayOfLines) {
const [time, ...line] = element.split(' ');
if (time !== logQueryTime) {
core.info(line.join(' '));
} else {
break;
}
}
if (podStatus.body?.status?.phase === 'Failed') {
throw new Error('Kubernetes job failed');
}
logQueryTime = arrayOfLines[0].split(' ')[0];
}
}
await new Promise((resolve) => {
logs.response.on('data', (chunk) => {
core.info(chunk);
});
logs.response.on('close', resolve);
logs.response.on('end', resolve);
});
}
static async cleanup() {

5887
yarn-error.log 100644

File diff suppressed because it is too large Load Diff