Skip to content

Commit

Permalink
fix(scalecluster): ensure the target capacity is less than max
Browse files Browse the repository at this point in the history
Adds another check to enxure that the request to scale the cluster is within the acceptable range.
  • Loading branch information
theBenForce committed Jan 7, 2020
1 parent 8201a12 commit 641ab8a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tasks/scaleCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ const UPDATE_DELAY = 1000;
export default async (ctx: Context) => {
const rds = new RDS({ region: ctx.region });

const target = ctx.minCapacity || 1;
let target = ctx.minCapacity || ctx.capacity.MinCapcity;
target = Math.max(target, ctx.capacity.MinCapcity);
target = Math.min(target, ctx.capacity.MaxCapacity);

await rds
.modifyCurrentDBClusterCapacity({
DBClusterIdentifier: ctx.cluster,
Capacity: Math.max(target, ctx.capacity.MinCapcity)
Capacity: target
})
.promise();

Expand Down

0 comments on commit 641ab8a

Please sign in to comment.