Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

feat(infra): configure runner machine types per stage (#2994)

zombee0138b5cb0d2dc
diff --git a/apps/infra/docs/configuration.md b/apps/infra/docs/configuration.md
index c8e435fc8..883454d43 100644
--- a/apps/infra/docs/configuration.md
+++ b/apps/infra/docs/configuration.md
@@ -78,12 +78,22 @@ the secret does not. Use `.env.example` for the names and defaults.
## Runner sizing
-`deploy.runners` in the stage declaration requires `size` (`small`, `medium` or `large`) and
-`rootDiskGb`. GCP also accepts optional `dataDiskGb` for a new runner's separate data disk:
+`deploy.runners.size` selects `small`, `medium`, `large`, `xlarge` or `2xlarge`.
+The two largest tiers default to `n4-standard-32` and `n4-standard-64` on GCP,
+and `c8i.4xlarge` and `c8i.8xlarge` on AWS.
+
+In each stage, optional
+`machineTypes` entries override the cloud machine for individual tiers. Choose
+machines that support nested virtualization and the runner's disk configuration.
+For example, a GCP stage can configure its runners as follows:
```json
{
- "size": "large",
+ "size": "xlarge",
+ "machineTypes": {
+ "xlarge": "n4d-standard-32",
+ "2xlarge": "n4d-standard-64"
+ },
"rootDiskGb": 100,
"dataDiskGb": 2048
}
diff --git a/apps/infra/mdeploy/src/config.ts b/apps/infra/mdeploy/src/config.ts
index 70e0b36f5..7a9245d5f 100644
--- a/apps/infra/mdeploy/src/config.ts
+++ b/apps/infra/mdeploy/src/config.ts
@@ -33,7 +33,7 @@ import type { AlarmRequest, AlarmThreshold } from '../stack/alarms.ts'
import type { CacheRequest, CacheSize } from '../stack/cache.ts'
import type { ClickHouseMode, ClickHouseRequest } from '../stack/clickhouse.ts'
import type { DatabaseRequest, DatabaseSize } from '../stack/database.ts'
-import type { RunnerRequest, RunnerSize } from '../stack/runners.ts'
+import { RUNNER_SIZES, type RunnerRequest } from '../stack/runners.ts'
import type { StorageRequest } from '../stack/storage.ts'
export class DeployConfigError extends Error {
@@ -44,7 +44,7 @@ export class DeployConfigError extends Error {
}
/** The runner settings a config file decides. The fleet and the binary do not. */
-export type RunnerSettings = Pick<RunnerRequest, 'size' | 'rootDiskGb' | 'dataDiskGb'>
+export type RunnerSettings = Pick<RunnerRequest, 'size' | 'rootDiskGb' | 'dataDiskGb' | 'machineTypes'>
export type DeployConfig = {
/** The stage file the block was read out of. */
@@ -93,7 +93,6 @@ const VOLUME_PREFIX = 'boxlite-volume'
const DATABASE_SIZES: DatabaseSize[] = ['small', 'standard', 'medium']
const CACHE_SIZES: CacheSize[] = ['small', 'medium']
-const RUNNER_SIZES: RunnerSize[] = ['small', 'medium', 'large']
const CLICKHOUSE_MODES: ClickHouseMode[] = ['self-hosted', 'managed', 'disabled']
/** RDS keeps at most 35 days of automated backups; below one means none. */
@@ -249,13 +248,22 @@ const parseClickHouse = (
const parseRunners = (raw: unknown, where: string, { partial }: { partial: boolean }): Partial<RunnerSettings> => {
const block = assertObject(raw, where)
- assertKeys(block, ['size', 'rootDiskGb', 'dataDiskGb'], where, { partial: true })
+ assertKeys(block, ['size', 'rootDiskGb', 'dataDiskGb', 'machineTypes'], where, { partial: true })
const missing = ['size', 'rootDiskGb'].filter((key) => !(key in block))
if (!partial && missing.length) throw new DeployConfigError(`${where} must set ${missing.join(', ')}`)
const parsed: Partial<RunnerSettings> = {}
if ('size' in block) parsed.size = assertOneOf(block.size, RUNNER_SIZES, `${where}.size`)
if ('rootDiskGb' in block) parsed.rootDiskGb = assertWholeNumber(block.rootDiskGb, `${where}.rootDiskGb`, DISK_BOUNDS)
if ('dataDiskGb' in block) parsed.dataDiskGb = assertWholeNumber(block.dataDiskGb, `${where}.dataDiskGb`, DISK_BOUNDS)
+ if ('machineTypes' in block) {
+ const path = `${where}.machineTypes`
+ const types = assertObject(block.machineTypes, path)
+ assertKeys(types, RUNNER_SIZES, path, { partial: true })
+ parsed.machineTypes = {}
+ for (const size of RUNNER_SIZES) {
+ if (size in types) parsed.machineTypes[size] = assertPattern(types[size], /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/, `${path}.${size}`)
+ }
+ }
return parsed
}
diff --git a/apps/infra/mdeploy/stack/providers/aws/runners.ts b/apps/infra/mdeploy/stack/providers/aws/runners.ts
index ce5993810..b350ababe 100644
--- a/apps/infra/mdeploy/stack/providers/aws/runners.ts
+++ b/apps/infra/mdeploy/stack/providers/aws/runners.ts
@@ -32,8 +32,7 @@
*/
import type { Placement } from '../../network.ts'
-import type { RunnerProvider, RunnerRequest, Runners } from '../../runners.ts'
-import { RUNNER_PORT, RUNNER_TOKEN_VARIABLE } from '../../runners.ts'
+import { RUNNER_PORT, RUNNER_TOKEN_VARIABLE, type RunnerProvider, type RunnerRequest, type Runners } from '../../runners.ts'
import { renderRunnerBoot, type BootPlatform } from '../../runner-boot.ts'
import {
REGISTER_RUNNERS_COMMAND,
@@ -50,7 +49,13 @@ import {
} from '../../runner-upgrade.ts'
/** What each requested size answers to. Every one of these can nest. */
-const INSTANCE = { small: 'c8i.large', medium: 'c8i.xlarge', large: 'c8i.2xlarge' } as const
+const INSTANCE = {
+ small: 'c8i.large',
+ medium: 'c8i.xlarge',
+ large: 'c8i.2xlarge',
+ xlarge: 'c8i.4xlarge',
+ '2xlarge': 'c8i.8xlarge',
+} as const
const UBUNTU_OWNER = '099720109477'
const UBUNTU_NAME = 'ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*'
@@ -230,7 +235,7 @@ rm -rf /tmp/awscliv2.zip /tmp/aws`,
slot.resourceName,
{
ami: ami.id,
- instanceType: INSTANCE[request.size],
+ instanceType: request.machineTypes?.[request.size] ?? INSTANCE[request.size],
// Public subnet, and the security group the network arranged is
// what makes the address egress-only.
subnetId: placement.subnets[0],
diff --git a/apps/infra/mdeploy/stack/providers/gcp/runners.ts b/apps/infra/mdeploy/stack/providers/gcp/runners.ts
index 8b5cd5163..b068ab0f9 100644
--- a/apps/infra/mdeploy/stack/providers/gcp/runners.ts
+++ b/apps/infra/mdeploy/stack/providers/gcp/runners.ts
@@ -55,7 +55,13 @@ import { volumeConditionFor } from './storage.ts'
* AMD-based ones other than N4D, and a host on one of those accepts work and
* fails every box.
*/
-export const MACHINE = { small: 'n4-standard-4', medium: 'n4-standard-8', large: 'n4-standard-16' } as const
+export const MACHINE = {
+ small: 'n4-standard-4',
+ medium: 'n4-standard-8',
+ large: 'n4-standard-16',
+ xlarge: 'n4-standard-32',
+ '2xlarge': 'n4-standard-64',
+} as const
/**
* The only disk type N4 takes.
@@ -80,10 +86,13 @@ export const DISK_TYPE = 'hyperdisk-balanced'
* because a default is computed once at create and a disk grown later keeps it.
* Overriding capacity does not change these performance presets.
*/
+const standardDataDisk = { sizeGb: 200, iops: 3_600, throughputMiBps: 290 } as const
export const DATA_DISK = {
small: { sizeGb: 200, iops: 3_600, throughputMiBps: 240 },
- medium: { sizeGb: 200, iops: 3_600, throughputMiBps: 290 },
- large: { sizeGb: 200, iops: 3_600, throughputMiBps: 290 },
+ medium: standardDataDisk,
+ large: standardDataDisk,
+ xlarge: standardDataDisk,
+ '2xlarge': standardDataDisk,
} as const
/** What the data disk is attached as, so a host finds it at `/dev/disk/by-id/google-<this>`. */
@@ -495,7 +504,7 @@ udevadm trigger --name-match=kvm || true`,
name: slot.nameTag,
project,
zone,
- machineType: MACHINE[request.size],
+ machineType: request.machineTypes?.[request.size] ?? MACHINE[request.size],
// Explicitly, or the device is absent on a machine that can host it.
advancedMachineFeatures: { enableNestedVirtualization: request.nestedVirtualization },
bootDisk: {
diff --git a/apps/infra/mdeploy/stack/runners.ts b/apps/infra/mdeploy/stack/runners.ts
index 49eae279d..09d355fd1 100644
--- a/apps/infra/mdeploy/stack/runners.ts
+++ b/apps/infra/mdeploy/stack/runners.ts
@@ -32,7 +32,8 @@ import type { Placement } from './network.ts'
import type { RunnerArtifact } from './runner-binary.ts'
import { instanceFor } from 'naming'
-export type RunnerSize = 'small' | 'medium' | 'large'
+export const RUNNER_SIZES = ['small', 'medium', 'large', 'xlarge', '2xlarge'] as const
+export type RunnerSize = (typeof RUNNER_SIZES)[number]
/** One host, as the control plane will know it. */
export type RunnerSlot = {
@@ -101,6 +102,7 @@ export type RunnerBinary = {
export type RunnerRequest = {
size: RunnerSize
+ machineTypes?: Partial<Record<RunnerSize, string>>
rootDiskGb: number
/** GCP data volume at creation; omitted retains the provider default. Unsupported on AWS. */
dataDiskGb?: number
diff --git a/apps/infra/mdeploy/test/config.test.ts b/apps/infra/mdeploy/test/config.test.ts
index bd11c957e..4d6e083b7 100644
--- a/apps/infra/mdeploy/test/config.test.ts
+++ b/apps/infra/mdeploy/test/config.test.ts
@@ -30,6 +30,9 @@ const parse = (overrides: Record<string, unknown> = {}) =>
test('runner configuration accepts an optional data disk while preserving required fields and bounds', () => {
assert.deepEqual(parse().runners, valid.runners)
+ const runners = { ...valid.runners, size: '2xlarge', machineTypes: { medium: 'n4-standard-8', '2xlarge': 'n4d-standard-64' } }
+ assert.deepEqual(parse({ runners }).runners, runners)
+ assert.throws(() => parse({ runners: { ...runners, machineTypes: { tiny: 'n4-standard-4' } } }), /does not take tiny/)
for (const dataDiskGb of [20, 2048, 4000]) {
const runners = { ...valid.runners, dataDiskGb }
assert.deepEqual(parse({ runners }).runners, runners)
diff --git a/apps/infra/mdeploy/test/gcp-pitfalls.test.ts b/apps/infra/mdeploy/test/gcp-pitfalls.test.ts
index c46d203b9..718c1e64d 100644
--- a/apps/infra/mdeploy/test/gcp-pitfalls.test.ts
+++ b/apps/infra/mdeploy/test/gcp-pitfalls.test.ts
@@ -1179,6 +1179,8 @@ test('every runner size states a data disk GCP will create and its machine can u
'n4-standard-4': { iops: 30_000, throughputMiBps: 240 },
'n4-standard-8': { iops: 30_000, throughputMiBps: 480 },
'n4-standard-16': { iops: 80_000, throughputMiBps: 1_200 },
+ 'n4-standard-32': { iops: 100_000, throughputMiBps: 1_600 },
+ 'n4-standard-64': { iops: 160_000, throughputMiBps: 2_400 },
}
for (const [size, machine] of Object.entries(RUNNER_MACHINE)) {
const disk = DATA_DISK[size as keyof typeof DATA_DISK]
diff --git a/apps/infra/mdeploy/test/runner-sizing.test.ts b/apps/infra/mdeploy/test/runner-sizing.test.ts
index 27d581394..5fed71871 100644
--- a/apps/infra/mdeploy/test/runner-sizing.test.ts
+++ b/apps/infra/mdeploy/test/runner-sizing.test.ts
@@ -101,6 +101,8 @@ test('GCP keeps existing machine types while supplying the requested size for ne
for (const [size, machineType] of [
['small', 'n4-standard-4'],
['large', 'n4-standard-16'],
+ ['xlarge', 'n4-standard-32'],
+ ['2xlarge', 'n4-standard-64'],
] as const) {
provider(requestFor(size))
const host = resources.get('Runner')!
@@ -109,6 +111,8 @@ test('GCP keeps existing machine types while supplying the requested size for ne
assert.equal(host.args.deletionProtection, true)
assert.equal(host.options.protect, true)
}
+ provider({ ...requestFor('small'), machineTypes: { small: 'n4-standard-8' } })
+ assert.equal(resources.get('Runner')!.args.machineType, 'n4-standard-8')
})
test('GCP honors an explicit data disk capacity and retains the default and disk protections', (t) => {
@@ -138,6 +142,7 @@ test('AWS refuses a GCP data disk size before creating resources', (t) => {
const request = { ...requestFor(), dataDiskGb: 2048 }
assert.throws(() => provider(request), /AWS runners do not support dataDiskGb; configure rootDiskGb instead/)
assert.equal(resources.size, 0)
- provider(requestFor())
+ provider({ ...requestFor('2xlarge'), machineTypes: { '2xlarge': 'c8i.12xlarge' } })
+ assert.equal(resources.get('Runner')!.args.instanceType, 'c8i.12xlarge')
assert.equal(resources.get('Runner')!.args.rootBlockDevice.volumeSize, 100)
})