Skip to content

Commit

Permalink
Add automatic step-scaling calculation logic; add copy-ram-disk-on-up…
Browse files Browse the repository at this point in the history
…grade and remove volume takeover
  • Loading branch information
dimikot committed May 15, 2024
1 parent 479b0f3 commit 4046c27
Show file tree
Hide file tree
Showing 14 changed files with 1,656 additions and 946 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ module.exports = (projectRoot, extraRules = {}) => ({
"@typescript-eslint/no-useless-constructor": ["error"],
"@typescript-eslint/prefer-optional-chain": ["error"],
"@typescript-eslint/consistent-type-imports": ["error"],
"@typescript-eslint/require-array-sort-compare": [
"error",
{ ignoreStringArrays: true },
],
eqeqeq: ["error"],
"object-shorthand": ["error", "always"],
"@typescript-eslint/unbound-method": ["error"],
Expand Down
42 changes: 16 additions & 26 deletions docs/classes/CiStorage.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Construct.constructor

#### Defined in

[src/CiStorage.ts:184](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L184)
[src/CiStorage.ts:198](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L198)

## Properties

Expand All @@ -63,17 +63,17 @@ Construct.constructor

#### Defined in

[src/CiStorage.ts:173](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L173)
[src/CiStorage.ts:185](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L185)

___

### securityGroup

`Readonly` **securityGroup**: `ISecurityGroup`
`Readonly` **securityGroup**: `SecurityGroup`

#### Defined in

[src/CiStorage.ts:174](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L174)
[src/CiStorage.ts:186](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L186)

___

Expand All @@ -83,7 +83,7 @@ ___

#### Defined in

[src/CiStorage.ts:175](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L175)
[src/CiStorage.ts:187](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L187)

___

Expand All @@ -93,7 +93,7 @@ ___

#### Defined in

[src/CiStorage.ts:176](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L176)
[src/CiStorage.ts:188](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L188)

___

Expand All @@ -110,7 +110,7 @@ ___

#### Defined in

[src/CiStorage.ts:177](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L177)
[src/CiStorage.ts:189](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L189)

___

Expand All @@ -120,7 +120,7 @@ ___

#### Defined in

[src/CiStorage.ts:178](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L178)
[src/CiStorage.ts:190](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L190)

___

Expand All @@ -130,7 +130,7 @@ ___

#### Defined in

[src/CiStorage.ts:179](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L179)
[src/CiStorage.ts:191](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L191)

___

Expand All @@ -140,27 +140,17 @@ ___

#### Defined in

[src/CiStorage.ts:180](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L180)
[src/CiStorage.ts:192](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L192)

___

### hostInstances
### hosts

`Readonly` **hostInstances**: `Instance`[] = `[]`
`Readonly` **hosts**: \{ `fqdn`: `undefined` \| `string` ; `instance`: `Instance` }[] = `[]`

#### Defined in

[src/CiStorage.ts:181](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L181)

___

### hostVolumes

`Readonly` **hostVolumes**: `CfnVolume`[] = `[]`

#### Defined in

[src/CiStorage.ts:182](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L182)
[src/CiStorage.ts:193](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L193)

___

Expand All @@ -170,7 +160,7 @@ ___

#### Defined in

[src/CiStorage.ts:185](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L185)
[src/CiStorage.ts:199](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L199)

___

Expand All @@ -180,7 +170,7 @@ ___

#### Defined in

[src/CiStorage.ts:186](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L186)
[src/CiStorage.ts:200](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L200)

___

Expand All @@ -190,4 +180,4 @@ ___

#### Defined in

[src/CiStorage.ts:187](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L187)
[src/CiStorage.ts:201](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L201)
37 changes: 21 additions & 16 deletions docs/interfaces/CiStorageProps.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ VPC to use by this construct.

#### Defined in

[src/CiStorage.ts:56](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L56)
[src/CiStorage.ts:57](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L57)

___

Expand All @@ -30,19 +30,20 @@ instances.

#### Defined in

[src/CiStorage.ts:59](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L59)
[src/CiStorage.ts:60](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L60)

___

### securityGroupId
### instanceNamePrefix

**securityGroupId**: `string`
**instanceNamePrefix**: `string`

Id of the Security Group to set for the created instances.
All instance names (and hostname for the host instances) will be prefixed
with that value, separated by "-".

#### Defined in

[src/CiStorage.ts:61](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L61)
[src/CiStorage.ts:63](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L63)

___

Expand All @@ -61,7 +62,7 @@ A Hosted Zone to register the host instances in.

#### Defined in

[src/CiStorage.ts:63](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L63)
[src/CiStorage.ts:65](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L65)

___

Expand All @@ -74,7 +75,7 @@ must pre-exist.

#### Defined in

[src/CiStorage.ts:71](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L71)
[src/CiStorage.ts:73](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L73)

___

Expand All @@ -86,7 +87,7 @@ Time zone for instances, example: America/Los_Angeles.

#### Defined in

[src/CiStorage.ts:73](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L73)
[src/CiStorage.ts:75](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L75)

___

Expand All @@ -104,19 +105,22 @@ Configuration for self-hosted runner instances in the pool.
| `ghDockerComposeDirectoryUrl` | `string` | URL of docker-compose.yml (or compose.yml) directory. The tool will sparse-checkout that directory. The format is Dockerfile-compatible: https://github.com/owner/repo[#[branch]:/directory/with/compose/] |
| `imageSsmName` | `string` | SSM parameter name which holds the reference to an instance image. |
| `volumeGb` | `number` | Size of the root volume. |
| `swapSizeGb?` | `number` | Size of swap file (if you need it). |
| `tmpfsMaxSizeGb?` | `number` | If set, mounts /var/lib/docker to tmpfs with the provided max size. |
| `instanceRequirements` | [`InstanceRequirementsProperty`, ...InstanceRequirementsProperty[]] | The list of requirements to choose Spot Instances. |
| `scale` | \{ `onDemandPercentageAboveBaseCapacity`: `number` ; `maxActiveRunnersPercent`: \{ `periodSec`: `number` ; `value`: `number` } ; `minCapacity`: \{ `id`: `string` ; `value`: `number` ; `cron`: \{ `timeZone?`: `string` } & `CronOptions` }[] ; `maxCapacity`: `number` ; `maxInstanceLifetime`: `Duration` } | Scaling options. |
| `scale` | \{ `onDemandPercentageAboveBaseCapacity`: `number` ; `maxActiveRunnersPercent`: \{ `periodSec`: `number` ; `value`: `number` ; `scalingSteps?`: `number` } ; `minCapacity`: \{ `id`: `string` ; `value`: `number` ; `cron`: \{ `timeZone?`: `string` } & `CronOptions` }[] ; `maxCapacity`: `number` ; `maxInstanceLifetime`: `Duration` } | Scaling options. |
| `scale.onDemandPercentageAboveBaseCapacity` | `number` | The percentages of On-Demand Instances and Spot Instances for your additional capacity. |
| `scale.maxActiveRunnersPercent` | \{ `periodSec`: `number` ; `value`: `number` } | Maximum percentage of active runners. If the MAX metric of number of active runners within the recent periodSec interval grows beyond this threshold, the autoscaling group will launch new instances until the percentage drops, or maxCapacity is reached. |
| `scale.maxActiveRunnersPercent` | \{ `periodSec`: `number` ; `value`: `number` ; `scalingSteps?`: `number` } | Maximum percentage of active runners. If the MAX metric of number of active runners within the recent periodSec interval grows beyond this threshold, the autoscaling group will launch new instances until the percentage drops, or maxCapacity is reached. |
| `scale.maxActiveRunnersPercent.periodSec` | `number` | Calculate MAX metric within that period. The higher is the value, the slower will the capacity lower (but it doesn't affect how fast will it increase). |
| `scale.maxActiveRunnersPercent.value` | `number` | Value to use for the target percentage of active (busy) runners. |
| `scale.maxActiveRunnersPercent.scalingSteps?` | `number` | Desired number of ScalingInterval items in scalingSteps. |
| `scale.minCapacity` | \{ `id`: `string` ; `value`: `number` ; `cron`: \{ `timeZone?`: `string` } & `CronOptions` }[] | Minimal number of idle runners to keep, depending on the daytime. If the auto scaling group has less than this number of instances, the new instances will be created. |
| `scale.maxCapacity` | `number` | Maximum total number of instances. |
| `scale.maxInstanceLifetime` | `Duration` | Re-create instances time to time. |

#### Defined in

[src/CiStorage.ts:75](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L75)
[src/CiStorage.ts:77](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L77)

___

Expand All @@ -133,13 +137,14 @@ runner has its localhost ports redirected to that instance.
| Name | Type | Description |
| :------ | :------ | :------ |
| `ghDockerComposeDirectoryUrl` | `string` | URL of docker-compose.yml (or compose.yml) directory. The tool will sparse-checkout that directory. The format is Dockerfile-compatible: https://github.com/owner/repo[#[branch]:/directory/with/compose/] |
| `dockerComposeProfiles?` | `string`[] | List of profiles from docker-compose to additionally start. |
| `imageSsmName` | `string` | SSM parameter name which holds the reference to an instance image. |
| `volumeIops` | `number` | IOPS of the docker volume. |
| `volumeThroughput` | `number` | Throughput of the docker volume in MiB/s. |
| `volumeGb` | `number` | Size of the docker volume. |
| `swapSizeGb?` | `number` | Size of swap file (if you need it). |
| `tmpfsMaxSizeGb?` | `number` | If set, mounts /var/lib/docker to tmpfs with the provided max size and copies it from the old instance when the instance gets replaced. |
| `instanceType` | `string` | Full name of the Instance type. |
| `machines` | `number` | Number of instances to create. |
| `ports` | \{ `port`: `Port` ; `description`: `string` }[] | Ports to be open in the security group for connection from all runners to the host. |

#### Defined in

[src/CiStorage.ts:130](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L130)
[src/CiStorage.ts:138](https://github.com/clickup/ci-storage-cdk/blob/master/src/CiStorage.ts#L138)
2 changes: 1 addition & 1 deletion internal/clean.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
set -e

rm -rf dist yarn.lock package-lock.json pnpm-lock.yaml *.log
rm -rf dist yarn.lock package-lock.json pnpm-lock.yaml node_modules ./*.log
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@clickup/ci-storage-cdk",
"description": "A CDK construct to deploy ci-storage infrastructure",
"version": "2.10.293",
"version": "2.10.294",
"license": "MIT",
"keywords": [
"cdk",
Expand All @@ -15,7 +15,7 @@
"build": "$npm_execpath run clean; tsc",
"dev": "tsc --watch --preserveWatchOutput",
"lint": "bash internal/lint.sh",
"test": "jest",
"test": "$npm_execpath run build && jest",
"docs": "bash internal/docs.sh",
"clean": "rm -rf dist yarn.lock package-lock.json pnpm-lock.yaml *.log",
"copy-package-to-public-dir": "copy-package-to-public-dir.sh",
Expand Down
Loading

0 comments on commit 4046c27

Please sign in to comment.