pull/496/head
Frostebite 2023-03-06 18:27:58 +00:00
parent 50b5a7d942
commit f5bd8a7dde
3 changed files with 11 additions and 13 deletions

8
dist/index.js vendored
View File

@ -4035,7 +4035,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const stream_1 = __nccwpck_require__(12781);
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
const core = __importStar(__nccwpck_require__(42186));
const cloud_runner_statics_1 = __nccwpck_require__(90828);
const async_wait_until_1 = __importDefault(__nccwpck_require__(41299));
const follow_log_stream_service_1 = __nccwpck_require__(64121);
const cloud_runner_system_1 = __nccwpck_require__(99393);
@ -4051,8 +4050,7 @@ class KubernetesTaskRunner {
let shouldCleanup = true;
stream._write = (chunk, encoding, next) => {
didStreamAnyLogs = true;
let message = chunk.toString().trimRight(`\n`);
message = `[${cloud_runner_statics_1.CloudRunnerStatics.logPrefix}] ${message}`;
const message = chunk.toString().split(`Z `)[1].trimRight(`\n`);
({ shouldReadLogs, shouldCleanup, output } = follow_log_stream_service_1.FollowLogStreamService.handleIteration(message, shouldReadLogs, shouldCleanup, output));
next();
};
@ -4145,13 +4143,14 @@ class KubernetesTaskRunner {
static watchUntilPodRunning(kubeClient, podName, namespace) {
return __awaiter(this, void 0, void 0, function* () {
let success = false;
let message = ``;
cloud_runner_logger_1.default.log(`Watching ${podName} ${namespace}`);
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(`Phase:${(_b = status.body.status) === null || _b === void 0 ? void 0 : _b.phase} \n Reason:${((_d = (_c = status.body.status) === null || _c === void 0 ? void 0 : _c.conditions) === null || _d === void 0 ? void 0 : _d[0].reason) || ''} \n Message:${((_f = (_e = status.body.status) === null || _e === void 0 ? void 0 : _e.conditions) === null || _f === void 0 ? void 0 : _f[0].message) || ''}`);
message = `Phase:${(_b = status.body.status) === null || _b === void 0 ? void 0 : _b.phase} \n Reason:${((_d = (_c = status.body.status) === null || _c === void 0 ? void 0 : _c.conditions) === null || _d === void 0 ? void 0 : _d[0].reason) || ''} \n 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 {
@ -4168,6 +4167,7 @@ class KubernetesTaskRunner {
timeout: 2000000,
intervalBetweenAttempts: 15000,
});
cloud_runner_logger_1.default.log(message);
return success;
});
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,6 @@ import { CoreV1Api, KubeConfig } from '@kubernetes/client-node';
import { Writable } from 'stream';
import CloudRunnerLogger from '../../services/cloud-runner-logger';
import * as core from '@actions/core';
import { CloudRunnerStatics } from '../../cloud-runner-statics';
import waitUntil from 'async-wait-until';
import { FollowLogStreamService } from '../../services/follow-log-stream-service';
import { CloudRunnerSystem } from '../../services/cloud-runner-system';
@ -28,8 +27,7 @@ class KubernetesTaskRunner {
let shouldCleanup = true;
stream._write = (chunk, encoding, next) => {
didStreamAnyLogs = true;
let message = chunk.toString().trimRight(`\n`);
message = `[${CloudRunnerStatics.logPrefix}] ${message}`;
const message = chunk.toString().split(`Z `)[1].trimRight(`\n`);
({ shouldReadLogs, shouldCleanup, output } = FollowLogStreamService.handleIteration(
message,
shouldReadLogs,
@ -140,17 +138,16 @@ class KubernetesTaskRunner {
static async watchUntilPodRunning(kubeClient: CoreV1Api, podName: string, namespace: string) {
let success: boolean = false;
let message = ``;
CloudRunnerLogger.log(`Watching ${podName} ${namespace}`);
await waitUntil(
async () => {
const status = await kubeClient.readNamespacedPodStatus(podName, namespace);
const phase = status?.body.status?.phase;
success = phase === 'Running';
CloudRunnerLogger.log(
`Phase:${status.body.status?.phase} \n Reason:${
status.body.status?.conditions?.[0].reason || ''
} \n Message:${status.body.status?.conditions?.[0].message || ''}`,
);
message = `Phase:${status.body.status?.phase} \n Reason:${
status.body.status?.conditions?.[0].reason || ''
} \n Message:${status.body.status?.conditions?.[0].message || ''}`;
CloudRunnerLogger.log(
JSON.stringify(
(await kubeClient.listNamespacedEvent(namespace)).body.items
@ -175,6 +172,7 @@ class KubernetesTaskRunner {
intervalBetweenAttempts: 15000,
},
);
CloudRunnerLogger.log(message);
return success;
}