Fail build if no logs come through then list namespace events

pull/273/head
Frostebite 2021-06-19 19:35:55 +01:00
parent c5bc5bf86f
commit 9c441a87f5
3 changed files with 23 additions and 1 deletions

8
dist/index.js vendored
View File

@ -1646,7 +1646,9 @@ class Kubernetes {
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();
let didStreamAnyLogs = false;
stream._write = (chunk, encoding, next) => {
didStreamAnyLogs = true;
core.info(chunk.toString());
next();
};
@ -1660,6 +1662,12 @@ class Kubernetes {
if (resultError) {
throw resultError;
}
if (!didStreamAnyLogs) {
throw new Error(JSON.stringify({
message: 'Failed to stream any logs, listing namespace events',
items: (yield this.kubeClient.listNamespacedEvent(this.namespace)).body.items,
}, undefined, 4));
}
}
catch (error) {
throw error;

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -448,7 +448,9 @@ class Kubernetes implements RemoteBuilderProviderInterface {
async streamLogs() {
core.info(`Streaming logs from pod: ${this.podName} container: ${this.containerName} namespace: ${this.namespace}`);
const stream = new Writable();
let didStreamAnyLogs: boolean = false;
stream._write = (chunk, encoding, next) => {
didStreamAnyLogs = true;
core.info(chunk.toString());
next();
};
@ -464,6 +466,18 @@ class Kubernetes implements RemoteBuilderProviderInterface {
if (resultError) {
throw resultError;
}
if (!didStreamAnyLogs) {
throw new Error(
JSON.stringify(
{
message: 'Failed to stream any logs, listing namespace events',
items: (await this.kubeClient.listNamespacedEvent(this.namespace)).body.items,
},
undefined,
4,
),
);
}
} catch (error) {
throw error;
}