Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture and propagate env info (TRIGGER_ENV) for socket and container providers #1733

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/hungry-moles-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"trigger.dev": patch
"@trigger.dev/core": patch
---

Add TRIGGER_ENV environment variable to task runs
1 change: 1 addition & 0 deletions apps/coordinator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ class TaskCoordinator {
setSocketDataFromHeader("runId", "x-trigger-run-id");
setSocketDataFromHeader("attemptFriendlyId", "x-trigger-attempt-friendly-id", false);
setSocketDataFromHeader("attemptNumber", "x-trigger-attempt-number", false);
setSocketDataFromHeader("env", "x-trigger-env");
setSocketDataFromHeader("envId", "x-trigger-env-id");
setSocketDataFromHeader("deploymentId", "x-trigger-deployment-id");
setSocketDataFromHeader("deploymentVersion", "x-trigger-deployment-version");
Expand Down
1 change: 1 addition & 0 deletions apps/docker-provider/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class DockerTaskOperations implements TaskOperations {
"--detach",
`--env=TRIGGER_ENV_ID=${opts.envId}`,
`--env=TRIGGER_RUN_ID=${opts.runId}`,
`--env=TRIGGER_ENV=${opts.envType}`,
`--env=OTEL_EXPORTER_OTLP_ENDPOINT=${OTEL_EXPORTER_OTLP_ENDPOINT}`,
`--env=POD_NAME=${containerName}`,
`--env=COORDINATOR_HOST=${COORDINATOR_HOST}`,
Expand Down
4 changes: 4 additions & 0 deletions apps/kubernetes-provider/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ class KubernetesTaskOperations implements TaskOperations {
name: "TRIGGER_RUN_ID",
value: opts.runId,
},
{
name: "TRIGGER_ENV",
value: opts.envType,
},
...(opts.dequeuedAt
? [{ name: "TRIGGER_RUN_DEQUEUED_AT_MS", value: String(opts.dequeuedAt) }]
: []),
Expand Down
2 changes: 2 additions & 0 deletions packages/cli-v3/src/entryPoints/deploy-run-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ cliLogger.debug("Starting prod worker", {
class ProdWorker {
private contentHash = env.TRIGGER_CONTENT_HASH!;
private projectRef = env.TRIGGER_PROJECT_REF!;
private env = env.TRIGGER_ENV!;
private envId = env.TRIGGER_ENV_ID!;
private runId = env.TRIGGER_RUN_ID!;
private deploymentId = env.TRIGGER_DEPLOYMENT_ID!;
Expand Down Expand Up @@ -671,6 +672,7 @@ class ProdWorker {
"x-trigger-content-hash": this.contentHash,
"x-trigger-project-ref": this.projectRef,
"x-trigger-env-id": this.envId,
"x-trigger-env": this.env,
"x-trigger-deployment-id": this.deploymentId,
"x-trigger-run-id": this.runId,
"x-trigger-deployment-version": this.deploymentVersion,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/v3/schemas/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ export const ProdWorkerSocketData = z.object({
contentHash: z.string(),
projectRef: z.string(),
envId: z.string(),
env: z.string(),
runId: z.string(),
attemptFriendlyId: z.string().optional(),
attemptNumber: z.string().optional(),
Expand Down