fix: k8s error handling

(cherry picked from commit f633a3efb42432a6d2492712aead865a950c8dca)
pull/472/head
Frostebite 2022-11-07 21:19:35 +00:00
parent 4cca069ebb
commit 0579324822
4 changed files with 24 additions and 5 deletions

14
dist/index.js vendored
View File

@ -2575,6 +2575,7 @@ class TaskService {
static awsListStacks(perResultCallback = false) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
cloud_runner_logger_1.default.log(`List Stacks`);
process.env.AWS_REGION = input_1.default.region;
const CF = new aws_sdk_1.default.CloudFormation();
const stacks = ((_a = (yield CF.listStacks().promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE')) || [];
@ -2600,6 +2601,7 @@ class TaskService {
}
static awsListTasks(perResultCallback = false) {
return __awaiter(this, void 0, void 0, function* () {
cloud_runner_logger_1.default.log(`List Tasks`);
process.env.AWS_REGION = input_1.default.region;
const ecs = new aws_sdk_1.default.ECS();
const clusters = (yield ecs.listClusters().promise()).clusterArns || [];
@ -2636,6 +2638,7 @@ class TaskService {
static awsListJobs(perResultCallback = false) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
cloud_runner_logger_1.default.log(`List Jobs`);
process.env.AWS_REGION = input_1.default.region;
const CF = new aws_sdk_1.default.CloudFormation();
const stacks = ((_a = (yield CF.listStacks().promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE' && _x.TemplateDescription !== base_stack_formation_1.BaseStackFormation.baseStackDecription)) || [];
@ -3046,8 +3049,15 @@ class Kubernetes {
}
}
catch (error) {
const reason = ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.reason) || error.reason || ``;
const errorMessage = error.message || ``;
let errorParsed;
try {
errorParsed = JSON.parse(error);
}
catch (_c) {
errorParsed = error;
}
const reason = errorParsed.reason || ((_b = (_a = errorParsed.response) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.reason) || ``;
const errorMessage = errorParsed.message || ``;
const continueStreaming = reason === `NotFound` || errorMessage.includes(`dial timeout, backstop`);
if (continueStreaming) {
cloud_runner_logger_1.default.log('Log Stream Container Not Found');

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -16,6 +16,7 @@ export class TaskService {
return output;
}
public static async awsListStacks(perResultCallback: any = false) {
CloudRunnerLogger.log(`List Stacks`);
process.env.AWS_REGION = Input.region;
const CF = new AWS.CloudFormation();
const stacks =
@ -55,6 +56,7 @@ export class TaskService {
}
}
public static async awsListTasks(perResultCallback: any = false) {
CloudRunnerLogger.log(`List Tasks`);
process.env.AWS_REGION = Input.region;
const ecs = new AWS.ECS();
const clusters = (await ecs.listClusters().promise()).clusterArns || [];
@ -88,6 +90,7 @@ export class TaskService {
}
}
public static async awsListJobs(perResultCallback: any = false) {
CloudRunnerLogger.log(`List Jobs`);
process.env.AWS_REGION = Input.region;
const CF = new AWS.CloudFormation();
const stacks =

View File

@ -155,8 +155,14 @@ class Kubernetes implements ProviderInterface {
CloudRunnerLogger.log('Pod still running, recovering stream...');
}
} catch (error: any) {
const reason = error.response?.body?.reason || error.reason || ``;
const errorMessage = error.message || ``;
let errorParsed;
try {
errorParsed = JSON.parse(error);
} catch {
errorParsed = error;
}
const reason = errorParsed.reason || errorParsed.response?.body?.reason || ``;
const errorMessage = errorParsed.message || ``;
const continueStreaming = reason === `NotFound` || errorMessage.includes(`dial timeout, backstop`);
if (continueStreaming) {