Skip to content

Commit 4b10b25

Browse files
committed
Fixes for allocating concurrency where it didn't calculate correctly
1 parent d874a64 commit 4b10b25

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.concurrency/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ function Upgradable({
301301

302302
const allocatedInProject = Array.from(allocation.values()).reduce((e, acc) => e + acc, 0);
303303
const initialAllocationInProject = allocationTotal(environments);
304-
const unallocated = extraConcurrency - allocatedInProject;
305304
const changeInAllocation = allocatedInProject - initialAllocationInProject;
305+
const unallocated = extraUnallocatedConcurrency - changeInAllocation;
306306
const allocationModified = changeInAllocation !== 0;
307307

308308
return (

apps/webapp/app/v3/services/allocateConcurrency.server.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,16 @@ export class AllocateConcurrencyService extends BaseService {
3838
};
3939
}
4040

41-
const totalExtra = environments.reduce((acc, e) => e.amount + acc, 0);
41+
const previousExtra = result.environments.reduce(
42+
(acc, e) => Math.max(0, e.maximumConcurrencyLimit - e.planConcurrencyLimit) + acc,
43+
0
44+
);
45+
const newExtra = environments.reduce((acc, e) => e.amount + acc, 0);
46+
const change = newExtra - previousExtra;
47+
48+
const totalExtra = result.extraAllocatedConcurrency + change;
4249

43-
if (totalExtra > result.extraUnallocatedConcurrency) {
50+
if (change > result.extraUnallocatedConcurrency) {
4451
return {
4552
success: false,
4653
error: `You don't have enough unallocated concurrency available. You requested ${totalExtra} but only have ${result.extraUnallocatedConcurrency}.`,

0 commit comments

Comments
 (0)