error handling
parent
292f787c26
commit
1051a8c125
|
|
@ -731,7 +731,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const k8s = __importStar(__webpack_require__(89679));
|
const k8s = __importStar(__webpack_require__(89679));
|
||||||
const core = __webpack_require__(42186);
|
const core = __importStar(__webpack_require__(42186));
|
||||||
const base64 = __webpack_require__(85848);
|
const base64 = __webpack_require__(85848);
|
||||||
const pollInterval = 50000;
|
const pollInterval = 50000;
|
||||||
class Kubernetes {
|
class Kubernetes {
|
||||||
|
|
@ -1037,14 +1037,21 @@ class Kubernetes {
|
||||||
static watchBuildJobUntilFinished() {
|
static watchBuildJobUntilFinished() {
|
||||||
var _a, _b, _c, _d;
|
var _a, _b, _c, _d;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
try {
|
||||||
const pod = (yield Kubernetes.watchPodUntilReadyAndRead('Pending')) || {};
|
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)}`);
|
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);
|
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) {
|
static streamLogs(name, namespace) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
try {
|
||||||
let running = true;
|
let running = true;
|
||||||
let logQueryTime;
|
let logQueryTime;
|
||||||
while (running) {
|
while (running) {
|
||||||
|
|
@ -1067,6 +1074,10 @@ class Kubernetes {
|
||||||
const pod = yield this.kubeClient.readNamespacedPod(name, namespace);
|
const pod = yield this.kubeClient.readNamespacedPod(name, namespace);
|
||||||
running = ((_b = pod.body.status) === null || _b === void 0 ? void 0 : _b.phase) === 'Running';
|
running = ((_b = pod.body.status) === null || _b === void 0 ? void 0 : _b.phase) === 'Running';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static cleanup() {
|
static cleanup() {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,7 +1,7 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import * as k8s from '@kubernetes/client-node';
|
import * as k8s from '@kubernetes/client-node';
|
||||||
import { BuildParameters } from '.';
|
import { BuildParameters } from '.';
|
||||||
const core = require('@actions/core');
|
import * as core from '@actions/core';
|
||||||
const base64 = require('base-64');
|
const base64 = require('base-64');
|
||||||
|
|
||||||
const pollInterval = 50000;
|
const pollInterval = 50000;
|
||||||
|
|
@ -319,6 +319,7 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async watchBuildJobUntilFinished() {
|
static async watchBuildJobUntilFinished() {
|
||||||
|
try {
|
||||||
const pod = (await Kubernetes.watchPodUntilReadyAndRead('Pending')) || {};
|
const pod = (await Kubernetes.watchPodUntilReadyAndRead('Pending')) || {};
|
||||||
|
|
||||||
core.info(
|
core.info(
|
||||||
|
|
@ -329,9 +330,14 @@ class Kubernetes {
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
await Kubernetes.streamLogs(pod.metadata?.name || '', this.namespace);
|
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) {
|
static async streamLogs(name: string, namespace: string) {
|
||||||
|
try {
|
||||||
let running = true;
|
let running = true;
|
||||||
let logQueryTime;
|
let logQueryTime;
|
||||||
while (running) {
|
while (running) {
|
||||||
|
|
@ -365,6 +371,9 @@ class Kubernetes {
|
||||||
const pod = await this.kubeClient.readNamespacedPod(name, namespace);
|
const pod = await this.kubeClient.readNamespacedPod(name, namespace);
|
||||||
running = pod.body.status?.phase === 'Running';
|
running = pod.body.status?.phase === 'Running';
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async cleanup() {
|
static async cleanup() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue