Skip to content

fix(otel): run the collector and its file exports from node-local /tmp - #6215

Merged
wprazuch merged 3 commits into
mainfrom
wprazuch/otel-collector-node-local
Nov 16, 2026
Merged

wprazuch merged 3 commits into
mainfrom
wprazuch/otel-collector-node-local

Conversation

@wprazuch

@wprazuch wprazuch commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

The OTel collector ran straight from otel.binary, often a path on shared storage, and its file exporters appended metrics.jsonl, traces.jsonl and logs.jsonl into <job dir>/otel/ for the whole run, one span per traced vLLM request. Executing code and streaming small appends on a shared parallel file system both load it for the whole job.

  • The collector step copies otel.binary into a private node-local dir (mktemp -d /tmp/gym-otel-<slurm job id>.XXXXXX) and runs the copy.
  • The file/* exporters write to that dir. When the collector exits, its step appends each jsonl to <job dir>/otel/ and removes the dir.
  • The step forwards Slurm's TERM to the collector and waits for its flush before copying.
  • The shutdown pkill matches the node-local copy. When the collector runs beside a driver that is not on the batch host, the pkill runs on that node through srun. Before, it missed there and the step was killed without a flush.
  • resubmit keeps the old in-job-dir exporter paths for a job.sh that predates the copy step, and a refused rerender restores the collector config together with job.sh.
  • The shutdown wait goes from 30 s to 120 s to cover flush plus copy. It still ends as soon as the step exits.

The files are appended, not written per job: the names and layout stay what readers already see, and the exporter already appended across resume segments. The copy runs in the collector's own step because that step may be on another node or in a container, so it is the only place that sees its own /tmp.

Validation

  • Unit tests for the rendered step, the exporter paths, the pkill pattern (expanded by bash, then matched against the copy, srun and the wrapper), the remote-node stop, and the resubmit config choice.
  • A local end-to-end test runs the step with a fake collector, sends TERM, and checks the files are appended after an earlier segment's.
  • Regenerated the PD job-script fixtures.
  • pytest tests/unit_tests/orchestration: 3171 passed; the 54 failures fail identically on main on this macOS machine (BSD tool differences).
  • pre-commit run --files <changed files> passes.
  • Not yet run on a cluster.

Rollouts

N/A: telemetry plumbing only.

Compatibility and benchmark impact

None for results. otel/*.jsonl now fill in when the collector stops instead of during the run; remote OTLP export is unchanged. Needs room for the jsonl in node /tmp.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally.
  • Documentation added or updated (eval-submit-collector.mdx).
  • Pre-commit checks pass locally (on the changed files).
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s).

The collector step copies otel.binary into a private node-local
directory (mktemp under /tmp, named after the Slurm job id), runs the
copy, and points the three file exporters there. When the collector
exits, the same step appends each jsonl to <job dir>/otel/ and removes
the node-local directory, so shared storage sees one sequential write
per file per job instead of an append per batch.

The shutdown pkill matches the node-local copy and, when the collector
runs beside a driver that is not on the batch host, runs on that node.
Resubmit keeps the in-job-dir exporter paths for a job.sh that predates
the copy step.

Signed-off-by: Wojciech Prazuch <[email protected]>
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 16, 2026 10:23
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP WITH CARE

I found one RISK: a refused repin can restore an older job script while leaving its collector configuration on incompatible node-local exporter paths.

I inspected all nine changed files and traced startup, shutdown, and resubmit compatibility. One parallel report was unavailable, so I completed its collector-wrapper inspection myself. This was static review; I did not execute tests or validate Slurm runtime behavior.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

return f"printf %s {shlex.quote(collector_yaml)} > {collector_path} || fail 'cannot update collector config'"

# An older job.sh never copies node-local jsonl into the job dir, so its collector writes there.
collector_update = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RISK: roll back the collector configuration with the job script.

By source inspection, an OTel-enabled run with a pre-wrapper job.sh becomes internally incompatible after a refused repin to this revision. repin_commands installs the new script before this marker check, so this branch writes ${env:GYM_OTEL_LOCAL_DIR}/*.jsonl. If sbatch refuses the request, the exit trap restores only the script and resolved configuration. The restored script never exports that variable or copies files out. Queuing that restored script directly therefore cannot deliver telemetry to its promised job-directory paths, despite the refusal reporting job_dir_restored: true. Before this change, the exporter paths did not depend on the script version.

Could _rerender_commands back up and restore the collector configuration in the same transaction? The invariant is that a refused rerender restores a compatible script/configuration pair. After constructing restore, this insertion provides the missing backup:

collector_backup = []
if otel_active(config):
    collector = shlex.quote(str(collector_config_path(job_dir)))
    kept_collector = shlex.quote(
        f"{collector_config_path(job_dir)}.pre-{kinds[0]}-{stamp}"
    )
    collector_backup = [
        f"cp -p {collector} {kept_collector} || fail 'cannot keep collector config before rendering'"
    ]
    restore += f"; mv -f {kept_collector} {collector} 2>/dev/null"

Expand *collector_backup into commands before installing _gym_restore_repin. Please verify this suggestion before adopting it. Keep successful rerenders on node-local paths, ordinary legacy resubmits on job-directory paths, and active-run refusal before any collector update. Token fallback must still apply to successfully queued attempts.

Proposed acceptance checks, not executed: extend the repin refusal test with OTel enabled, a pre-wrapper script and direct exporter paths. Force the existing deterministic scheduler refusal and assert byte-for-byte restoration of the script, resolved configuration and collector configuration. With submission accepted, assert that the new script exports GYM_OTEL_LOCAL_DIR and all three exporters reference it. Retain the legacy/new-script path assertions and the active-run unchanged-config assertion.

…nder

A refused repin or walltime rerender restored job.sh and the resolved
config but kept the collector config the resubmit had rewritten for
node-local paths, so the restored older job.sh would start a collector
writing to an unset GYM_OTEL_LOCAL_DIR. Back the collector config up
with the script and restore it in the same exit trap.

Also note on the collector docs page how large the node-local jsonl
can grow, so node /tmp is sized for it.

Signed-off-by: Wojciech Prazuch <[email protected]>
…config

A run staged with OTel off has no otel/collector.yaml, but its saved
config can still enable the collector, so the rerender's unconditional
backup aborted a repin that worked before. Back the file up only when
it exists; on a refused rerender move the backup back, or remove the
collector config the resubmit wrote when there was none.

Signed-off-by: Wojciech Prazuch <[email protected]>
@wprazuch
wprazuch added this pull request to the merge queue Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43904642177

Merged via the queue into main with commit f0c2feb Nov 16, 2026
68 checks passed
@wprazuch
wprazuch deleted the wprazuch/otel-collector-node-local branch November 16, 2026 16:24
@svcnvidia-nemo-ci svcnvidia-nemo-ci added bug Something isn't working area:orchestration Job submission, deployment, services, and lifecycle management ready-to-merge PR is approved, current, and waiting for final CI or merge labels Nov 16, 2026
prokotg added a commit that referenced this pull request Nov 17, 2026
Ports main's changes to the files this PR moved:
- orchestration/recovery.py (#6210, #6080, #6223): 3 symbols changed and 6 added, into the eval/recovery
  modules; NO_ELIGIBLE_RETRY_REASON moves to eval/recovery/markers.py because the evidence reader now
  uses it.
- executors/slurm.py (#6210, #6223, #6215): the 12 hunks, into executors/slurm/chain.py, judge_job.py and
  reader.py.
- tests that import the old module paths (the otel, resubmit and recovery tests added since).

Signed-off-by: Tomasz Grzegorzek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:orchestration Job submission, deployment, services, and lifecycle management bug Something isn't working ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants