Skip to content

Commit 5e8188b

Browse files
authored
Merge pull request #1 from dimension-studios-inc/feat/cpu-mem-request-override
Feat/cpu mem request override
2 parents cf9398b + 77edb1f commit 5e8188b

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

apps/kubernetes-provider/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,8 @@ class KubernetesTaskOperations implements TaskOperations {
545545

546546
#getResourceRequestsForMachine(preset: MachinePreset): ResourceQuantities {
547547
return {
548-
cpu: `${preset.cpu * 0.75}`,
549-
memory: `${preset.memory}G`,
548+
cpu: `${preset.cpuRequest ?? preset.cpu * 0.75}`,
549+
memory: `${preset.memoryRequest ?? preset.memory}G`,
550550
};
551551
}
552552

apps/supervisor/src/workloadManager/kubernetes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ export class KubernetesWorkloadManager implements WorkloadManager {
296296

297297
#getResourceRequestsForMachine(preset: MachinePreset): ResourceQuantities {
298298
return {
299-
cpu: `${preset.cpu * 0.75}`,
300-
memory: `${preset.memory}G`,
299+
cpu: `${preset.cpuRequest ?? preset.cpu * 0.75}`,
300+
memory: `${preset.memoryRequest ?? preset.memory}G`,
301301
};
302302
}
303303

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ type Machines = typeof machinesFromPlatform;
8080

8181
const MachineOverrideValues = z.object({
8282
cpu: z.number(),
83+
cpuRequest: z.number().optional(), // Only used for k8s fallback to cpu
8384
memory: z.number(),
85+
memoryRequest: z.number().optional(), // Only used for k8s fallback to memory
8486
});
8587
type MachineOverrideValues = z.infer<typeof MachineOverrideValues>;
8688

docs/self-hosting/overview.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ While [limits](#limits) are generally configurable when self-hosting, some featu
4141
| Community support ||| Access to our Discord community |
4242
| ARM support ||| ARM-based deployments |
4343

44-
4544
## Limits
4645

4746
Most of the [limits](/limits) are configurable when self-hosting, with some hardcoded exceptions. You can configure them via environment variables on the [webapp](/self-hosting/env/webapp) container.
@@ -92,6 +91,18 @@ All fields are optional. Partial overrides are supported:
9291
}
9392
```
9493

94+
You can also set cpu/memory requests for each machine type. This is used in k8s environments to set the minimum resources required for each machine type.
95+
We do not recommend setting these values to zero, as it can cause the k8s scheduler to schedule an infinite number of pods in parallel and cause the pods to get killed due to resource exhaustion.
96+
97+
```json
98+
{
99+
"defaultMachine": "small-2x",
100+
"machines": {
101+
"small-1x": { "cpu": 0.5, "memory": 0.5, "cpuRequest": 0.25, "memoryRequest": 0.25 }
102+
}
103+
}
104+
```
105+
95106
## Community support
96107

97108
It's dangerous to go alone! Join the self-hosting channel on our [Discord server](https://discord.gg/NQTxt5NA7s).

packages/core/src/v3/schemas/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@ export const MachinePreset = z.object({
118118
name: MachinePresetName,
119119
/** unit: vCPU */
120120
cpu: z.number(),
121+
cpuRequest: z.number().optional(), // Only used for k8s fallback to cpu
121122
/** unit: GB */
122123
memory: z.number(),
124+
memoryRequest: z.number().optional(), // Only used for k8s fallback to memory
123125
centsPerMs: z.number(),
124126
});
125127

0 commit comments

Comments
 (0)