K8s task loop, fail early

pull/496/head
Frostebite 2023-02-08 18:31:49 +00:00
parent b324d78732
commit e3f32d587b
3 changed files with 29 additions and 26 deletions

28
dist/index.js generated vendored
View File

@ -3308,7 +3308,7 @@ class Kubernetes {
}); });
} }
runTaskInWorkflow(buildGuid, image, commands, mountdir, workingdir, environment, secrets) { runTaskInWorkflow(buildGuid, image, commands, mountdir, workingdir, environment, secrets) {
var _a, _b, _c, _d; var _a, _b;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
cloud_runner_logger_1.default.log('Cloud Runner K8s workflow!'); cloud_runner_logger_1.default.log('Cloud Runner K8s workflow!');
@ -3329,7 +3329,7 @@ class Kubernetes {
cloud_runner_logger_1.default.log(JSON.stringify((_a = status.body.status) === null || _a === void 0 ? void 0 : _a.containerStatuses, undefined, 4)); cloud_runner_logger_1.default.log(JSON.stringify((_a = status.body.status) === null || _a === void 0 ? void 0 : _a.containerStatuses, undefined, 4));
existsAlready = true; existsAlready = true;
} }
catch (_e) { catch (_c) {
// empty // empty
} }
if (!existsAlready || ((_b = status.state) === null || _b === void 0 ? void 0 : _b.terminated) !== undefined) { if (!existsAlready || ((_b = status.state) === null || _b === void 0 ? void 0 : _b.terminated) !== undefined) {
@ -3353,20 +3353,22 @@ class Kubernetes {
yield this.cleanupTaskResources(); yield this.cleanupTaskResources();
} }
catch (error) { catch (error) {
let errorParsed; // let errorParsed;
try { try {
errorParsed = JSON.parse(error); // errorParsed = JSON.parse(error);
} }
catch (_f) { catch (_d) {
errorParsed = error; // errorParsed = error;
} }
const errorMessage = errorParsed.name || errorParsed.reason || ((_d = (_c = errorParsed.response) === null || _c === void 0 ? void 0 : _c.body) === null || _d === void 0 ? void 0 : _d.reason) || errorParsed.message; // const errorMessage =
const continueStreaming = errorMessage.includes(`dial timeout, backstop`) || // errorParsed.name || errorParsed.reason || errorParsed.response?.body?.reason || errorParsed.message;
errorMessage.includes(`HttpError`) || const continueStreaming = false;
errorMessage.includes(`HttpError: HTTP request failed`) || // errorMessage.includes(`dial timeout, backstop`) ||
errorMessage.includes(`an error occurred when try to find container`) || // errorMessage.includes(`HttpError`) ||
errorMessage.includes(`not found`) || // errorMessage.includes(`HttpError: HTTP request failed`) ||
errorMessage.includes(`Not Found`); // errorMessage.includes(`an error occurred when try to find container`) ||
// errorMessage.includes(`not found`) ||
// errorMessage.includes(`Not Found`);
if (continueStreaming) { if (continueStreaming) {
cloud_runner_logger_1.default.log('Log Stream Container Not Found'); cloud_runner_logger_1.default.log('Log Stream Container Not Found');
yield new Promise((resolve) => resolve(5000)); yield new Promise((resolve) => resolve(5000));

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -169,23 +169,24 @@ class Kubernetes implements ProviderInterface {
} }
await this.cleanupTaskResources(); await this.cleanupTaskResources();
} catch (error: any) { } catch (error: any) {
let errorParsed; // let errorParsed;
try { try {
errorParsed = JSON.parse(error); // errorParsed = JSON.parse(error);
} catch { } catch {
errorParsed = error; // errorParsed = error;
} }
const errorMessage = // const errorMessage =
errorParsed.name || errorParsed.reason || errorParsed.response?.body?.reason || errorParsed.message; // errorParsed.name || errorParsed.reason || errorParsed.response?.body?.reason || errorParsed.message;
const continueStreaming = const continueStreaming = false;
errorMessage.includes(`dial timeout, backstop`) ||
errorMessage.includes(`HttpError`) || // errorMessage.includes(`dial timeout, backstop`) ||
errorMessage.includes(`HttpError: HTTP request failed`) || // errorMessage.includes(`HttpError`) ||
errorMessage.includes(`an error occurred when try to find container`) || // errorMessage.includes(`HttpError: HTTP request failed`) ||
errorMessage.includes(`not found`) || // errorMessage.includes(`an error occurred when try to find container`) ||
errorMessage.includes(`Not Found`); // errorMessage.includes(`not found`) ||
// errorMessage.includes(`Not Found`);
if (continueStreaming) { if (continueStreaming) {
CloudRunnerLogger.log('Log Stream Container Not Found'); CloudRunnerLogger.log('Log Stream Container Not Found');
await new Promise((resolve) => resolve(5000)); await new Promise((resolve) => resolve(5000));