Skip to content

Commit

Permalink
Merge pull request #3432 from artilleryio/fix/fargate-retries-launch-…
Browse files Browse the repository at this point in the history
…count
  • Loading branch information
hassy authored Dec 11, 2024
2 parents 4a6a5aa + 83cfac3 commit 7ae41b4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/artillery/lib/platform/aws-ecs/legacy/run-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,19 @@ async function ecsRunTask(context) {

try {
const runData = await ecs.runTask(params).promise();

const launchedTasksCount = runData.tasks?.length || 0;
tasksRemaining -= launchedTasksCount;

if (launchedTasksCount > 0) {
const newTaskArns = runData.tasks.map((task) => task.taskArn);
context.taskArns = context.taskArns.concat(newTaskArns);
artillery.globalEvents.emit('metadata', {
platformMetadata: { taskArns: newTaskArns }
});
debug(`Launched ${launchedTasksCount} tasks`);
}

if (runData.failures.length > 0) {
artillery.log('Some workers failed to start');
const uniqueReasons = [
Expand All @@ -1723,19 +1736,6 @@ async function ecsRunTask(context) {
await sleep(10 * 1000);
throw new Error('Not enough ECS capacity');
}

if (runData.tasks?.length > 0) {
const newTaskArns = runData.tasks.map((task) => task.taskArn);
context.taskArns = context.taskArns.concat(newTaskArns);
artillery.globalEvents.emit('metadata', {
platformMetadata: { taskArns: newTaskArns }
});
debug(`Launched ${launchCount} tasks`);
tasksRemaining -= launchCount;
await sleep(250);
} else {
retries++;
}
} catch (runErr) {
if (runErr.code === 'ThrottlingException') {
artillery.log('ThrottlingException returned from ECS, retrying');
Expand Down

0 comments on commit 7ae41b4

Please sign in to comment.