Fail build if no logs come through then list namespace events
parent
c5bc5bf86f
commit
9c441a87f5
|
|
@ -1646,7 +1646,9 @@ class Kubernetes {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Streaming logs from pod: ${this.podName} container: ${this.containerName} namespace: ${this.namespace}`);
|
core.info(`Streaming logs from pod: ${this.podName} container: ${this.containerName} namespace: ${this.namespace}`);
|
||||||
const stream = new stream_1.Writable();
|
const stream = new stream_1.Writable();
|
||||||
|
let didStreamAnyLogs = false;
|
||||||
stream._write = (chunk, encoding, next) => {
|
stream._write = (chunk, encoding, next) => {
|
||||||
|
didStreamAnyLogs = true;
|
||||||
core.info(chunk.toString());
|
core.info(chunk.toString());
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
@ -1660,6 +1662,12 @@ class Kubernetes {
|
||||||
if (resultError) {
|
if (resultError) {
|
||||||
throw 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) {
|
catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -448,7 +448,9 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
async streamLogs() {
|
async streamLogs() {
|
||||||
core.info(`Streaming logs from pod: ${this.podName} container: ${this.containerName} namespace: ${this.namespace}`);
|
core.info(`Streaming logs from pod: ${this.podName} container: ${this.containerName} namespace: ${this.namespace}`);
|
||||||
const stream = new Writable();
|
const stream = new Writable();
|
||||||
|
let didStreamAnyLogs: boolean = false;
|
||||||
stream._write = (chunk, encoding, next) => {
|
stream._write = (chunk, encoding, next) => {
|
||||||
|
didStreamAnyLogs = true;
|
||||||
core.info(chunk.toString());
|
core.info(chunk.toString());
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
@ -464,6 +466,18 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
if (resultError) {
|
if (resultError) {
|
||||||
throw 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) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue