follow logs
parent
645ce0ff06
commit
6136d05e28
|
|
@ -1010,11 +1010,17 @@ class Kubernetes {
|
||||||
core.info('Job created');
|
core.info('Job created');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static watchBuildJobUntilFinished() {
|
static watchPodUntilReadyAndRead() {
|
||||||
var _a, _b, _c, _d, _e, _f;
|
var _a, _b, _c;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let podname, containerId;
|
|
||||||
let ready = false;
|
let ready = false;
|
||||||
|
new Promise(() => setTimeout(() => {
|
||||||
|
if (!ready) {
|
||||||
|
const error = new Error('failed to find pod - timeout');
|
||||||
|
core.error(error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}, pollInterval * 15));
|
||||||
while (!ready) {
|
while (!ready) {
|
||||||
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
||||||
const pods = yield this.kubeClient.listNamespacedPod(this.namespace);
|
const pods = yield this.kubeClient.listNamespacedPod(this.namespace);
|
||||||
|
|
@ -1029,14 +1035,19 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ready = true;
|
ready = true;
|
||||||
podname = (_d = element.metadata) === null || _d === void 0 ? void 0 : _d.name;
|
return element;
|
||||||
containerId = (_f = (_e = element.status) === null || _e === void 0 ? void 0 : _e.containerStatuses) === null || _f === void 0 ? void 0 : _f[0].containerID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.info(`Watching build job ${podname}`);
|
});
|
||||||
const logs = yield this.kubeClient.readNamespacedPodLog(podname, this.namespace, containerId, true);
|
}
|
||||||
|
static watchBuildJobUntilFinished() {
|
||||||
|
var _a, _b, _c, _d;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const pod = (yield Kubernetes.watchPodUntilReadyAndRead()) || {};
|
||||||
|
core.info(`Watching build job ${(_a = pod.metadata) === null || _a === void 0 ? void 0 : _a.name}`);
|
||||||
|
const logs = yield this.kubeClient.readNamespacedPodLog(((_b = pod.metadata) === null || _b === void 0 ? void 0 : _b.name) || '', this.namespace, (_d = (_c = pod.status) === null || _c === void 0 ? void 0 : _c.containerStatuses) === null || _d === void 0 ? void 0 : _d[0].containerID, true);
|
||||||
yield new Promise((resolve, reject) => {
|
yield new Promise((resolve, reject) => {
|
||||||
logs.response.on('data', (chunk) => {
|
logs.response.on('data', (chunk) => {
|
||||||
core.info(chunk);
|
core.info(chunk);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -296,9 +296,18 @@ class Kubernetes {
|
||||||
core.info('Job created');
|
core.info('Job created');
|
||||||
}
|
}
|
||||||
|
|
||||||
static async watchBuildJobUntilFinished() {
|
static async watchPodUntilReadyAndRead() {
|
||||||
let podname, containerId;
|
|
||||||
let ready = false;
|
let ready = false;
|
||||||
|
new Promise(() =>
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!ready) {
|
||||||
|
const error = new Error('failed to find pod - timeout');
|
||||||
|
core.error(error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}, pollInterval * 15),
|
||||||
|
);
|
||||||
|
|
||||||
while (!ready) {
|
while (!ready) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
||||||
const pods = await this.kubeClient.listNamespacedPod(this.namespace);
|
const pods = await this.kubeClient.listNamespacedPod(this.namespace);
|
||||||
|
|
@ -312,16 +321,24 @@ class Kubernetes {
|
||||||
core.error('Kubernetes job failed');
|
core.error('Kubernetes job failed');
|
||||||
} else {
|
} else {
|
||||||
ready = true;
|
ready = true;
|
||||||
podname = element.metadata?.name;
|
return element;
|
||||||
containerId = element.status?.containerStatuses?.[0].containerID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
core.info(`Watching build job ${podname}`);
|
static async watchBuildJobUntilFinished() {
|
||||||
|
const pod = (await Kubernetes.watchPodUntilReadyAndRead()) || {};
|
||||||
|
|
||||||
const logs = await this.kubeClient.readNamespacedPodLog(podname, this.namespace, containerId, true);
|
core.info(`Watching build job ${pod.metadata?.name}`);
|
||||||
|
|
||||||
|
const logs = await this.kubeClient.readNamespacedPodLog(
|
||||||
|
pod.metadata?.name || '',
|
||||||
|
this.namespace,
|
||||||
|
pod.status?.containerStatuses?.[0].containerID,
|
||||||
|
true,
|
||||||
|
);
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
logs.response.on('data', (chunk) => {
|
logs.response.on('data', (chunk) => {
|
||||||
core.info(chunk);
|
core.info(chunk);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue