Skip to content

Commit 4a13ef6

Browse files
Merge branch 'main' into feat/sync-env-secrets
2 parents 142a685 + b3b2553 commit 4a13ef6

File tree

295 files changed

+18370
-4934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+18370
-4934
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Stop failing attempt spans when a run is cancelled

.changeset/kind-kids-teach.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"trigger.dev": patch
3+
"@trigger.dev/core": patch
4+
---
5+
6+
Added INSTALLING status to the deployment status enum.

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"**/node_modules/**": true,
77
"packages/cli-v3/e2e": true
88
},
9-
"vitest.disableWorkspaceWarning": true
9+
"vitest.disableWorkspaceWarning": true,
10+
"typescript.experimental.useTsgo": false
1011
}

CHANGESETS.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ Please follow the best-practice of adding changesets in the same commit as the c
3030

3131
## Snapshot instructions
3232

33-
1. Delete the `.changeset/pre.json` file (if it exists)
33+
1. Update the `.changeset/config.json` file to set the `"changelog"` field to this:
3434

35-
2. Do a temporary commit (do NOT push this, you should undo it after)
35+
```json
36+
"changelog": "@changesets/cli/changelog",
37+
```
3638

37-
3. Copy the `GITHUB_TOKEN` line from the .env file
39+
2. Do a temporary commit (do NOT push this, you should undo it after)
3840

39-
4. Run `GITHUB_TOKEN=github_pat_12345 ./scripts/publish-prerelease.sh re2`
41+
3. Run `./scripts/publish-prerelease.sh prerelease`
4042

41-
Make sure to replace the token with yours. `re2` is the tag that will be used for the pre-release.
43+
You can choose a different tag if you want, but usually `prerelease` is fine.
4244

43-
5. Undo the commit where you deleted the pre.json file.
45+
5. Undo the commit where you updated the config.json file.

apps/supervisor/src/env.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ const Env = z.object({
8585
KUBERNETES_EPHEMERAL_STORAGE_SIZE_LIMIT: z.string().default("10Gi"),
8686
KUBERNETES_EPHEMERAL_STORAGE_SIZE_REQUEST: z.string().default("2Gi"),
8787
KUBERNETES_STRIP_IMAGE_DIGEST: BoolEnv.default(false),
88+
KUBERNETES_CPU_REQUEST_MIN_CORES: z.coerce.number().min(0).default(0),
89+
KUBERNETES_CPU_REQUEST_RATIO: z.coerce.number().min(0).max(1).default(0.75), // Ratio of CPU limit, so 0.75 = 75% of CPU limit
90+
KUBERNETES_MEMORY_REQUEST_MIN_GB: z.coerce.number().min(0).default(0),
91+
KUBERNETES_MEMORY_REQUEST_RATIO: z.coerce.number().min(0).max(1).default(1), // Ratio of memory limit, so 1 = 100% of memory limit
92+
KUBERNETES_MEMORY_OVERHEAD_GB: z.coerce.number().min(0).optional(), // Optional memory overhead to add to the limit in GB
93+
KUBERNETES_SCHEDULER_NAME: z.string().optional(), // Custom scheduler name for pods
8894

8995
// Placement tags settings
9096
PLACEMENT_TAGS_ENABLED: BoolEnv.default(false),

apps/supervisor/src/workloadManager/kubernetes.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ export class KubernetesWorkloadManager implements WorkloadManager {
2020
private namespace = env.KUBERNETES_NAMESPACE;
2121
private placementTagProcessor: PlacementTagProcessor;
2222

23+
// Resource settings
24+
private readonly cpuRequestMinCores = env.KUBERNETES_CPU_REQUEST_MIN_CORES;
25+
private readonly cpuRequestRatio = env.KUBERNETES_CPU_REQUEST_RATIO;
26+
private readonly memoryRequestMinGb = env.KUBERNETES_MEMORY_REQUEST_MIN_GB;
27+
private readonly memoryRequestRatio = env.KUBERNETES_MEMORY_REQUEST_RATIO;
28+
private readonly memoryOverheadGb = env.KUBERNETES_MEMORY_OVERHEAD_GB;
29+
2330
constructor(private opts: WorkloadManagerOptions) {
2431
this.k8s = createK8sApi();
2532
this.placementTagProcessor = new PlacementTagProcessor({
@@ -63,6 +70,10 @@ export class KubernetesWorkloadManager implements WorkloadManager {
6370
return imageRef.substring(0, atIndex);
6471
}
6572

73+
private clamp(value: number, min: number, max: number): number {
74+
return Math.min(Math.max(value, min), max);
75+
}
76+
6677
async create(opts: WorkloadManagerCreateOptions) {
6778
this.logger.log("[KubernetesWorkloadManager] Creating container", { opts });
6879

@@ -263,6 +274,11 @@ export class KubernetesWorkloadManager implements WorkloadManager {
263274
restartPolicy: "Never",
264275
automountServiceAccountToken: false,
265276
imagePullSecrets: this.getImagePullSecrets(),
277+
...(env.KUBERNETES_SCHEDULER_NAME
278+
? {
279+
schedulerName: env.KUBERNETES_SCHEDULER_NAME,
280+
}
281+
: {}),
266282
...(env.KUBERNETES_WORKER_NODETYPE_LABEL
267283
? {
268284
nodeSelector: {
@@ -295,16 +311,27 @@ export class KubernetesWorkloadManager implements WorkloadManager {
295311
}
296312

297313
#getResourceRequestsForMachine(preset: MachinePreset): ResourceQuantities {
314+
const cpuRequest = preset.cpu * this.cpuRequestRatio;
315+
const memoryRequest = preset.memory * this.memoryRequestRatio;
316+
317+
// Clamp between min and max
318+
const clampedCpu = this.clamp(cpuRequest, this.cpuRequestMinCores, preset.cpu);
319+
const clampedMemory = this.clamp(memoryRequest, this.memoryRequestMinGb, preset.memory);
320+
298321
return {
299-
cpu: `${preset.cpu * 0.75}`,
300-
memory: `${preset.memory}G`,
322+
cpu: `${clampedCpu}`,
323+
memory: `${clampedMemory}G`,
301324
};
302325
}
303326

304327
#getResourceLimitsForMachine(preset: MachinePreset): ResourceQuantities {
328+
const memoryLimit = this.memoryOverheadGb
329+
? preset.memory + this.memoryOverheadGb
330+
: preset.memory;
331+
305332
return {
306333
cpu: `${preset.cpu}`,
307-
memory: `${preset.memory}G`,
334+
memory: `${memoryLimit}G`,
308335
};
309336
}
310337

apps/supervisor/src/workloadServer/index.ts

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
type WorkloadRunAttemptCompleteResponseBody,
1717
WorkloadRunAttemptStartRequestBody,
1818
type WorkloadRunAttemptStartResponseBody,
19-
type WorkloadRunLatestSnapshotResponseBody,
2019
WorkloadRunSnapshotsSinceResponseBody,
2120
type WorkloadServerToClientEvents,
2221
type WorkloadSuspendRunResponseBody,
@@ -126,7 +125,7 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
126125
}
127126

128127
private createHttpServer({ host, port }: { host: string; port: number }) {
129-
return new HttpServer({
128+
const httpServer = new HttpServer({
130129
port,
131130
host,
132131
metrics: {
@@ -322,28 +321,6 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
322321
},
323322
}
324323
)
325-
.route("/api/v1/workload-actions/runs/:runFriendlyId/snapshots/latest", "GET", {
326-
paramsSchema: WorkloadActionParams.pick({ runFriendlyId: true }),
327-
handler: async ({ req, reply, params }) => {
328-
const latestSnapshotResponse = await this.workerClient.getLatestSnapshot(
329-
params.runFriendlyId,
330-
this.runnerIdFromRequest(req)
331-
);
332-
333-
if (!latestSnapshotResponse.success) {
334-
this.logger.error("Failed to get latest snapshot", {
335-
runId: params.runFriendlyId,
336-
error: latestSnapshotResponse.error,
337-
});
338-
reply.empty(500);
339-
return;
340-
}
341-
342-
reply.json({
343-
execution: latestSnapshotResponse.data.execution,
344-
} satisfies WorkloadRunLatestSnapshotResponseBody);
345-
},
346-
})
347324
.route(
348325
"/api/v1/workload-actions/runs/:runFriendlyId/snapshots/since/:snapshotFriendlyId",
349326
"GET",
@@ -369,23 +346,6 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
369346
},
370347
}
371348
)
372-
.route("/api/v1/workload-actions/runs/:runFriendlyId/logs/debug", "POST", {
373-
paramsSchema: WorkloadActionParams.pick({ runFriendlyId: true }),
374-
bodySchema: WorkloadDebugLogRequestBody,
375-
handler: async ({ req, reply, params, body }) => {
376-
reply.empty(204);
377-
378-
if (!env.SEND_RUN_DEBUG_LOGS) {
379-
return;
380-
}
381-
382-
await this.workerClient.sendDebugLog(
383-
params.runFriendlyId,
384-
body,
385-
this.runnerIdFromRequest(req)
386-
);
387-
},
388-
})
389349
.route("/api/v1/workload-actions/deployments/:deploymentId/dequeue", "GET", {
390350
paramsSchema: z.object({
391351
deploymentId: z.string(),
@@ -410,6 +370,31 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
410370
reply.json(dequeueResponse.data satisfies WorkloadDequeueFromVersionResponseBody);
411371
},
412372
});
373+
374+
if (env.SEND_RUN_DEBUG_LOGS) {
375+
httpServer.route("/api/v1/workload-actions/runs/:runFriendlyId/logs/debug", "POST", {
376+
paramsSchema: WorkloadActionParams.pick({ runFriendlyId: true }),
377+
bodySchema: WorkloadDebugLogRequestBody,
378+
handler: async ({ req, reply, params, body }) => {
379+
reply.empty(204);
380+
381+
await this.workerClient.sendDebugLog(
382+
params.runFriendlyId,
383+
body,
384+
this.runnerIdFromRequest(req)
385+
);
386+
},
387+
});
388+
} else {
389+
// Lightweight mock route without schemas
390+
httpServer.route("/api/v1/workload-actions/runs/:runFriendlyId/logs/debug", "POST", {
391+
handler: async ({ reply }) => {
392+
reply.empty(204);
393+
},
394+
});
395+
}
396+
397+
return httpServer;
413398
}
414399

415400
private createWebsocketServer() {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export function MoveToTopIcon({ className }: { className?: string }) {
2+
return (
3+
<svg className={className} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
4+
<g clipPath="url(#clip0_17186_103975)">
5+
<path
6+
d="M12 21L12 9"
7+
stroke="currentColor"
8+
strokeWidth="2"
9+
strokeLinecap="round"
10+
strokeLinejoin="round"
11+
/>
12+
<path
13+
d="M3 3L21 3"
14+
stroke="currentColor"
15+
strokeWidth="2"
16+
strokeLinecap="round"
17+
strokeLinejoin="round"
18+
/>
19+
<path
20+
d="M16.5 11.5L12 7L7.5 11.5"
21+
stroke="currentColor"
22+
strokeWidth="2"
23+
strokeLinecap="round"
24+
strokeLinejoin="round"
25+
/>
26+
</g>
27+
<defs>
28+
<clipPath id="clip0_17186_103975">
29+
<rect width="24" height="24" fill="currentColor" />
30+
</clipPath>
31+
</defs>
32+
</svg>
33+
);
34+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export function MoveUpIcon({ className }: { className?: string }) {
2+
return (
3+
<svg className={className} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
4+
<g clipPath="url(#clip0_17177_110851)">
5+
<path
6+
d="M12 21L12 13"
7+
stroke="currentColor"
8+
strokeWidth="2"
9+
strokeLinecap="round"
10+
strokeLinejoin="round"
11+
/>
12+
<path
13+
d="M3 3L21 3"
14+
stroke="currentColor"
15+
strokeWidth="2"
16+
strokeLinecap="round"
17+
strokeLinejoin="round"
18+
/>
19+
<path
20+
d="M3 7L21 7"
21+
stroke="currentColor"
22+
strokeWidth="2"
23+
strokeLinecap="round"
24+
strokeLinejoin="round"
25+
/>
26+
<path
27+
d="M16.5 15.5L12 11L7.5 15.5"
28+
stroke="currentColor"
29+
strokeWidth="2"
30+
strokeLinecap="round"
31+
strokeLinejoin="round"
32+
/>
33+
</g>
34+
<defs>
35+
<clipPath id="clip0_17177_110851">
36+
<rect width="24" height="24" fill="currentColor" />
37+
</clipPath>
38+
</defs>
39+
</svg>
40+
);
41+
}

apps/webapp/app/components/DefinitionTooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function DefinitionTip({
1414
return (
1515
<TooltipProvider>
1616
<Tooltip disableHoverableContent>
17-
<TooltipTrigger>
17+
<TooltipTrigger className="text-left">
1818
<span className="cursor-default underline decoration-charcoal-500 decoration-dashed underline-offset-4 transition hover:decoration-charcoal-400">
1919
{children}
2020
</span>

0 commit comments

Comments
 (0)