fix logging

pull/265/head
Frostebite 2021-05-28 19:58:43 +01:00
parent caeeeb4573
commit ec58c24ea7
3 changed files with 36 additions and 17 deletions

14
dist/index.js vendored
View File

@ -1058,8 +1058,18 @@ class Kubernetes {
while (running) {
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
core.info('Polling logs...');
const logs = yield this.kubeClient.readNamespacedPodLog(name, namespace, undefined, undefined, undefined, undefined, undefined, undefined, logQueryTime, undefined, true);
const arrayOfLines = (_a = logs.body.match(/[^\n\r]+/g)) === null || _a === void 0 ? void 0 : _a.reverse();
let logs;
try {
logs = yield this.kubeClient.readNamespacedPodLog(name, namespace, undefined, undefined, undefined, undefined, undefined, undefined, logQueryTime, undefined, true);
}
catch (error) {
core.info(error);
if (error.message === 'HTTP request failed') {
core.info('!warning - K8S HTTP FAILED');
continue;
}
}
const arrayOfLines = (_a = logs === null || logs === void 0 ? void 0 : logs.body.match(/[^\n\r]+/g)) === null || _a === void 0 ? void 0 : _a.reverse();
if (arrayOfLines) {
for (const element of arrayOfLines) {
const [time, ...line] = element.split(' ');

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -344,20 +344,29 @@ class Kubernetes {
while (running) {
await new Promise((resolve) => setTimeout(resolve, pollInterval));
core.info('Polling logs...');
const logs = await this.kubeClient.readNamespacedPodLog(
name,
namespace,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
logQueryTime,
undefined,
true,
);
const arrayOfLines = logs.body.match(/[^\n\r]+/g)?.reverse();
let logs;
try {
logs = await this.kubeClient.readNamespacedPodLog(
name,
namespace,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
logQueryTime,
undefined,
true,
);
} catch (error) {
core.info(error);
if (error.message === 'HTTP request failed') {
core.info('!warning - K8S HTTP FAILED');
continue;
}
}
const arrayOfLines = logs?.body.match(/[^\n\r]+/g)?.reverse();
if (arrayOfLines) {
for (const element of arrayOfLines) {
const [time, ...line] = element.split(' ');