Skip to content

Commit

Permalink
feat(consul support): consul instance store (#163)
Browse files Browse the repository at this point in the history
* feat(consul support): consul instance store

add context to getInstanceGroup call

* adds intial consul support and unit test stub

* mock consul k/v client

* further fixes

* updates for consul group store

* updates for ctx passthrough
  • Loading branch information
aaronkvanmeerten authored Dec 9, 2024
1 parent 7088058 commit 6981366
Show file tree
Hide file tree
Showing 21 changed files with 719 additions and 113 deletions.
54 changes: 54 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@types/shortid": "0.0.31",
"@types/sshpk": "^1.17.3",
"bee-queue": "^1.6.0",
"consul": "^2.0.1",
"dotenv": "^16.3.1",
"dots-wrapper": "^3.11.3",
"envalid": "^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ app.put(
body('maxDesired').optional().isInt({ min: 0 }).withMessage('Value must be positive'),
body('desiredCount').optional().isInt({ min: 0 }).withMessage('Value must be positive'),
body().custom(async (value, { req }) => {
if (!(await validator.groupHasValidDesiredInput(req.params.name, value))) {
if (!(await validator.groupHasValidDesiredInput(req.context, req.params.name, value))) {
throw new Error('Desired count must be between min and max; min cannot be grater than max');
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/autoscaler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class AutoscaleProcessor {
}

try {
const group = await this.instanceGroupManager.getInstanceGroup(groupName);
const group = await this.instanceGroupManager.getInstanceGroup(ctx, groupName);
if (!group) {
throw new Error(`Group ${groupName} not found, failed to process autoscaling`);
}
Expand Down
7 changes: 6 additions & 1 deletion src/cloud_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ export default class CloudManager {
};
await this.instanceTracker.track(ctx, state);
if (isScaleDownProtected) {
await this.shutdownManager.setScaleDownProtected(ctx, instanceId, group.protectedTTLSec);
await this.shutdownManager.setScaleDownProtected(
ctx,
group.name,
instanceId,
group.protectedTTLSec,
);
ctx.logger.info(
`[CloudManager] Instance ${instanceId} from group ${group.name} is in protected mode`,
);
Expand Down
Loading

0 comments on commit 6981366

Please sign in to comment.