error handling

pull/265/head
Frostebite 2021-05-28 18:54:54 +01:00
parent 292f787c26
commit 1051a8c125
3 changed files with 82 additions and 62 deletions

13
dist/index.js vendored
View File

@ -731,7 +731,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
// @ts-ignore
const k8s = __importStar(__webpack_require__(89679));
const core = __webpack_require__(42186);
const core = __importStar(__webpack_require__(42186));
const base64 = __webpack_require__(85848);
const pollInterval = 50000;
class Kubernetes {
@ -1037,14 +1037,21 @@ class Kubernetes {
static watchBuildJobUntilFinished() {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
try {
const pod = (yield Kubernetes.watchPodUntilReadyAndRead('Pending')) || {};
core.info(`Watching build job ${(_a = pod.metadata) === null || _a === void 0 ? void 0 : _a.name} ${JSON.stringify((_c = (_b = pod.status) === null || _b === void 0 ? void 0 : _b.containerStatuses) === null || _c === void 0 ? void 0 : _c[0].state, undefined, 4)}`);
yield Kubernetes.streamLogs(((_d = pod.metadata) === null || _d === void 0 ? void 0 : _d.name) || '', this.namespace);
}
catch (error) {
core.error('Failed while watching build job');
throw error;
}
});
}
static streamLogs(name, namespace) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
try {
let running = true;
let logQueryTime;
while (running) {
@ -1067,6 +1074,10 @@ class Kubernetes {
const pod = yield this.kubeClient.readNamespacedPod(name, namespace);
running = ((_b = pod.body.status) === null || _b === void 0 ? void 0 : _b.phase) === 'Running';
}
}
catch (error) {
throw error;
}
});
}
static cleanup() {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
// @ts-ignore
import * as k8s from '@kubernetes/client-node';
import { BuildParameters } from '.';
const core = require('@actions/core');
import * as core from '@actions/core';
const base64 = require('base-64');
const pollInterval = 50000;
@ -319,6 +319,7 @@ class Kubernetes {
}
static async watchBuildJobUntilFinished() {
try {
const pod = (await Kubernetes.watchPodUntilReadyAndRead('Pending')) || {};
core.info(
@ -329,9 +330,14 @@ class Kubernetes {
)}`,
);
await Kubernetes.streamLogs(pod.metadata?.name || '', this.namespace);
} catch (error) {
core.error('Failed while watching build job');
throw error;
}
}
static async streamLogs(name: string, namespace: string) {
try {
let running = true;
let logQueryTime;
while (running) {
@ -365,6 +371,9 @@ class Kubernetes {
const pod = await this.kubeClient.readNamespacedPod(name, namespace);
running = pod.body.status?.phase === 'Running';
}
} catch (error) {
throw error;
}
}
static async cleanup() {