fix(cli-v3): forward TRIGGER_WORKER_INSTANCE_NAME into the managed run process env#4213
Conversation
🦋 Changeset detectedLatest commit: dcd100b The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Hi @brentshulman-silkline, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis change forwards the ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| Forward `TRIGGER_WORKER_INSTANCE_NAME` into the managed run process env | ||
|
|
||
| The Kubernetes workload manager already injects `TRIGGER_WORKER_INSTANCE_NAME` | ||
| (= `spec.nodeName`) into the run-controller container via the downward API, but | ||
| the managed run worker is forked with an explicit env allowlist | ||
| (`RunnerEnv.gatherProcessEnv()`) that dropped it. As a result the run process | ||
| could not attach the node as an OpenTelemetry `host.name` resource attribute, so | ||
| spans/logs exported to an off-node OTLP collector had no host (Datadog tags these | ||
| `issue_type:empty_hostname`). This forwards the value so `trigger.config.ts` | ||
| telemetry (or the worker itself) can surface the node/host. |
There was a problem hiding this comment.
🟡 Changeset description uses internal jargon instead of user-facing language
The changeset body names internal infrastructure and code paths (RunnerEnv.gatherProcessEnv(), Kubernetes downward API, Datadog, OTLP collector) (.changeset/forward-worker-instance-name.md:5-14), violating the repo rule that changeset descriptions must be written for users, not maintainers.
Impact: Internal implementation details will appear verbatim in public release notes, confusing end users.
Repo rule violation details
AGENTS.md states: "Write the description for users, not maintainers. Both changesets and .server-changes/ notes ship verbatim in user-visible release notes. Lead with what changed for the user - one plain sentence describing behavior, not implementation, and never naming internal tools or infra."
The .server-changes/README.md:47-48 reinforces: "Never name internal tools or infra. Observability stacks, internal services, infra components, monitoring backends, CI surfaces, AWS specifics - none of these belong in user-facing notes."
The current changeset body mentions: Kubernetes workload manager, downward API, RunnerEnv.gatherProcessEnv(), OpenTelemetry, OTLP collector, Datadog, trigger.config.ts telemetry internals. All of these are internal implementation details.
| Forward `TRIGGER_WORKER_INSTANCE_NAME` into the managed run process env | |
| The Kubernetes workload manager already injects `TRIGGER_WORKER_INSTANCE_NAME` | |
| (= `spec.nodeName`) into the run-controller container via the downward API, but | |
| the managed run worker is forked with an explicit env allowlist | |
| (`RunnerEnv.gatherProcessEnv()`) that dropped it. As a result the run process | |
| could not attach the node as an OpenTelemetry `host.name` resource attribute, so | |
| spans/logs exported to an off-node OTLP collector had no host (Datadog tags these | |
| `issue_type:empty_hostname`). This forwards the value so `trigger.config.ts` | |
| telemetry (or the worker itself) can surface the node/host. | |
| Forward the worker/node name into managed run processes so custom telemetry exporters can identify which host executed each run | |
Was this helpful? React with 👍 or 👎 to provide feedback.
Problem
On self-hosted Kubernetes, task-run spans and logs exported over OTLP to an
off-node collector (e.g. a central Datadog Agent) have an empty host. Datadog
tags every such span with
issue_type:empty_hostname. There is no supported wayfor a user's
trigger.config.tstelemetry resource to recover the node, becausethe node identity never reaches the run process.
Root cause
The Kubernetes workload manager already injects the node name into the
run-controller container via the downward API
(
apps/supervisor/src/workloadManager/kubernetes.ts):But the actual task-run worker is
fork()ed with an explicit, replaced envbuilt from
RunnerEnv.gatherProcessEnv()(an allowlist) plus the run's env(
packages/cli-v3/src/entryPoints/managed/taskRunProcessProvider.ts→packages/cli-v3/src/executions/taskRunProcess.ts).gatherProcessEnv()returnsonly
NODE_ENV, NODE_EXTRA_CA_CERTS, OTEL_EXPORTER_OTLP_ENDPOINT, TRIGGER_OTEL_EXPORTER_OTLP_ENDPOINT, UV_USE_IO_URING, soTRIGGER_WORKER_INSTANCE_NAME(and container-level vars generally) never reachprocess.envin the run process. The node identity is present in the pod butdropped before it can be used.
Fix
Add
TRIGGER_WORKER_INSTANCE_NAMEto the env returned byRunnerEnv.gatherProcessEnv()(it is already in theEnvschema and has agetter). One line + comment; see
change.diff.With this, a user can map it in their
trigger.config.ts:which clears
empty_hostnameand attributes the run to its actual node.Scope / risk
undefinedfilter drops it).TRIGGER_WORKER_INSTANCE_NAMEto therunner (
workloadManager/docker.ts), so this aligns k8s runs with that.Changeset
trigger.dev: patch — seechangeset.md.