follow logs
parent
968a9190d6
commit
fd9e9d058a
|
|
@ -1005,12 +1005,13 @@ class Kubernetes {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
job.spec.backoffLimit = 1;
|
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');
|
core.info('Job created');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static watchBuildJobUntilFinished() {
|
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* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let podname;
|
let podname;
|
||||||
let ready = false;
|
let ready = false;
|
||||||
|
|
@ -1034,35 +1035,14 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.info(`Watching build job ${podname}`);
|
core.info(`Watching build job ${podname}`);
|
||||||
let logQueryTime;
|
const logs = yield this.kubeClient.readNamespacedPodLog(podname, this.namespace, undefined, true);
|
||||||
let complete = false;
|
yield new Promise((resolve) => {
|
||||||
while (!complete) {
|
logs.response.on('data', (chunk) => {
|
||||||
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
core.info(chunk);
|
||||||
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') {
|
logs.response.on('close', resolve);
|
||||||
complete = true;
|
logs.response.on('end', resolve);
|
||||||
}
|
});
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static cleanup() {
|
static cleanup() {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -291,7 +291,8 @@ class Kubernetes {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
job.spec.backoffLimit = 1;
|
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');
|
core.info('Job created');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -318,39 +319,15 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info(`Watching build job ${podname}`);
|
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);
|
const logs = await this.kubeClient.readNamespacedPodLog(podname, this.namespace, undefined, true);
|
||||||
if (podStatus.body?.status?.phase !== 'Running') {
|
await new Promise((resolve) => {
|
||||||
complete = true;
|
logs.response.on('data', (chunk) => {
|
||||||
}
|
core.info(chunk);
|
||||||
|
});
|
||||||
const logs = await this.kubeClient.readNamespacedPodLog(podname, this.namespace, undefined, true);
|
logs.response.on('close', resolve);
|
||||||
|
logs.response.on('end', resolve);
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async cleanup() {
|
static async cleanup() {
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue