in apps/firelens-stability/lib/cloud/ecs.ts [215:255]
async function launchECSTasks(testCase: ITestCase, taskCount: number, ecs: AWS.ECS, taskDefinitionArn: string): Promise<string[]> {
let launchedTasks = [];
while (launchedTasks.length < taskCount) {
const launchCount = Math.min(10, taskCount - launchedTasks.length);
let result: PromiseResult<AWS.ECS.RunTaskResponse, AWS.AWSError>;
try {
result = await ecs.runTask({
enableExecuteCommand: true,
cluster: testCase.config.cluster,
taskDefinition: taskDefinitionArn!,
count: launchCount,
launchType: "FARGATE",
networkConfiguration: {
awsvpcConfiguration: {
subnets: testCase.config.taskVpcSubnets,
assignPublicIp: "DISABLED",
securityGroups: testCase.config.taskVpcSecurityGroups,
}
}
}).promise();
}
catch (err) {
console.error(`Error launching task: ${err}`);
return;
}
const launchedTaskArns = result.tasks!.map((task) => task.taskArn!);
console.log(launchedTaskArns.reduce((a,b)=>`${a} ${b}\n`, ""));
launchedTasks.push(...launchedTaskArns);
/* Retry failed tasks... */
const failedTasks = launchCount - launchedTaskArns.length;
if (failedTasks) {
console.log(` ⚠️ ${testCase.managed.caseNameUnique}, failed ${failedTasks} task launches. Will retry`);
await new Promise(resolve => setTimeout(resolve, 500)); /* slow down the async loop (20 per second) */
}
await new Promise(resolve => setTimeout(resolve, 500)); /* slow down the async loop (20 per second) */
}
return launchedTasks;
}