events log cleanup

pull/496/head
Frostebite 2023-02-15 01:34:36 +00:00
parent beff5eb6ff
commit cef784e8f8
3 changed files with 27 additions and 52 deletions

29
dist/index.js generated vendored
View File

@ -4094,21 +4094,21 @@ class KubernetesTaskRunner {
return __awaiter(this, void 0, void 0, function* () {
let success = false;
cloud_runner_logger_1.default.log(`Watching ${podName} ${namespace}`);
cloud_runner_logger_1.default.log(JSON.stringify((yield kubeClient.listNamespacedEvent(namespace)).body.items
.map((x) => {
return {
message: x.message || ``,
name: x.metadata.name || ``,
reason: x.reason || ``,
};
})
.filter((x) => x.name.includes(podName)), undefined, 4));
yield async_wait_until_1.default(() => __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f;
const status = yield kubeClient.readNamespacedPodStatus(podName, namespace);
const phase = (_a = status === null || status === void 0 ? void 0 : status.body.status) === null || _a === void 0 ? void 0 : _a.phase;
success = phase === 'Running';
cloud_runner_logger_1.default.log(`${(_b = status.body.status) === null || _b === void 0 ? void 0 : _b.phase} ${((_d = (_c = status.body.status) === null || _c === void 0 ? void 0 : _c.conditions) === null || _d === void 0 ? void 0 : _d[0].reason) || ''} ${((_f = (_e = status.body.status) === null || _e === void 0 ? void 0 : _e.conditions) === null || _f === void 0 ? void 0 : _f[0].message) || ''}`);
cloud_runner_logger_1.default.log(`Phase:${(_b = status.body.status) === null || _b === void 0 ? void 0 : _b.phase} Reason:${((_d = (_c = status.body.status) === null || _c === void 0 ? void 0 : _c.conditions) === null || _d === void 0 ? void 0 : _d[0].reason) || ''} Message:${((_f = (_e = status.body.status) === null || _e === void 0 ? void 0 : _e.conditions) === null || _f === void 0 ? void 0 : _f[0].message) || ''}`);
cloud_runner_logger_1.default.log(JSON.stringify((yield kubeClient.listNamespacedEvent(namespace)).body.items
.map((x) => {
return {
message: x.message || ``,
name: x.metadata.name || ``,
reason: x.reason || ``,
};
})
.filter((x) => x.name.includes(podName)), undefined, 4));
if (success || phase !== 'Pending')
return true;
return false;
@ -4116,15 +4116,6 @@ class KubernetesTaskRunner {
timeout: 2000000,
intervalBetweenAttempts: 15000,
});
cloud_runner_logger_1.default.log(JSON.stringify((yield kubeClient.listNamespacedEvent(namespace)).body.items
.map((x) => {
return {
message: x.message || ``,
name: x.metadata.name || ``,
reason: x.reason || ``,
};
})
.filter((x) => x.name.includes(podName)), undefined, 4));
return success;
});
}

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -120,31 +120,31 @@ class KubernetesTaskRunner {
static async watchUntilPodRunning(kubeClient: CoreV1Api, podName: string, namespace: string) {
let success: boolean = false;
CloudRunnerLogger.log(`Watching ${podName} ${namespace}`);
CloudRunnerLogger.log(
JSON.stringify(
(await kubeClient.listNamespacedEvent(namespace)).body.items
.map((x) => {
return {
message: x.message || ``,
name: x.metadata.name || ``,
reason: x.reason || ``,
};
})
.filter((x) => x.name.includes(podName)),
undefined,
4,
),
);
await waitUntil(
async () => {
const status = await kubeClient.readNamespacedPodStatus(podName, namespace);
const phase = status?.body.status?.phase;
success = phase === 'Running';
CloudRunnerLogger.log(
`${status.body.status?.phase} ${status.body.status?.conditions?.[0].reason || ''} ${
`Phase:${status.body.status?.phase} Reason:${status.body.status?.conditions?.[0].reason || ''} Message:${
status.body.status?.conditions?.[0].message || ''
}`,
);
CloudRunnerLogger.log(
JSON.stringify(
(await kubeClient.listNamespacedEvent(namespace)).body.items
.map((x) => {
return {
message: x.message || ``,
name: x.metadata.name || ``,
reason: x.reason || ``,
};
})
.filter((x) => x.name.includes(podName)),
undefined,
4,
),
);
if (success || phase !== 'Pending') return true;
return false;
@ -155,22 +155,6 @@ class KubernetesTaskRunner {
},
);
CloudRunnerLogger.log(
JSON.stringify(
(await kubeClient.listNamespacedEvent(namespace)).body.items
.map((x) => {
return {
message: x.message || ``,
name: x.metadata.name || ``,
reason: x.reason || ``,
};
})
.filter((x) => x.name.includes(podName)),
undefined,
4,
),
);
return success;
}
}