remote-jobs.md 5.9 KB

Exact-source remote jobs

The existing tools/remote/prod2u-remote-job.sh and Windows tools/windows/remote-run.ps1 forward to tools/remote_job.py. Run its --help for argument details. Source synchronization remains Git over SSH to the LAN bare repository; checkout the exact commit in a clean build snapshot first.

Linux host example (options can follow the run ID; the command follows --):

python3 tools/remote_job.py submit motor-sim-ATTEMPT \
  --snapshot-id SNAPSHOT --target mrdimm-chamber --task smoke \
  --toolchain-id ENVIRONMENT-ID --workspace /data/prod2u/build-snapshots/SNAPSHOT \
  -- python3 -m pytest tests/unit/test_remote_job.py
python3 tools/remote_job.py status motor-sim-ATTEMPT
python3 tools/remote_job.py logs motor-sim-ATTEMPT
python3 tools/remote_job.py cancel motor-sim-ATTEMPT

From Windows, add --ssh-runner and the exact remote copy of this script before the action. Arguments are quoted for the remote POSIX shell by Python, including spaces and Chinese characters. Only the configured edk2-uefi-lab host is used. The native Windows Python executable runs the client; compilation remains Linux.

python tools/remote_job.py --ssh-runner /data/prod2u/build-snapshots/SNAPSHOT/tools/remote_job.py status motor-sim-ATTEMPT

Submission records snapshot/target/task/toolchain identifiers, full commit/tree, exact command and runner hash. run_id is immutable. Concurrent identical submissions start one systemd unit; later submissions return existing state. Changed arguments or input identity with the same ID are rejected. A new attempt uses a new ID. Empty commands are rejected and cannot produce PASS.

The systemd unit is detached from SSH. The worker waits for host attachment to a dedicated child cgroup of the existing privileged task container before starting the command. This includes descendants that call setsid, such as TD subprocesses. Cancel kills this job cgroup, and the supervisor records CANCELLED. A queued heavy job can be cancelled before it starts. Commands that exit leaving background processes receive FAIL and those processes are terminated. The container itself and other task cgroups are retained.

Heavy tasks td, formal, build, full, and package automatically use the existing heavy lock; --heavy covers other expensive commands. All running jobs hold the shared container lifecycle lock. Tools retain their documented phase timeouts. The generic SSH invoker does not repeat commands after either a remote error or an ambiguous SSH disconnect. Repeating an immutable submission is safe.

The run directory is available as PROD2U_RUN_DIR inside the command. Put native logs, reports and artifacts there. RUN-STATUS and RESULT record phase, exit code, boot/process/cgroup identity, log paths and a streamed SHA256 artifact inventory. PASS means the command exited zero without leaked processes; product acceptance must still inspect the command's native reports and test scope.

Status uses boot ID and live cgroup state. A different boot invalidates old PID identities and marks unfinished work INTERRUPTED. An inactive worker with no remaining job processes is also INTERRUPTED. A transient systemctl query failure is an observation error, not a terminal result. This avoids restarting an unobserved but still live command. No job is automatically restarted after reboot.

Live source53629cd checks exercised three concurrent duplicate submissions, continued execution after the submitting SSH sessions ended, rejection of changed arguments, native exit7, cancellation of a separate process group, and cleanup of leaked background children. Boot-change handling has a unit fixture; an actual host reboot was not performed. Artifact transport now uses the shared resumable tools/remote_transfer.py implementation. Cross-run content cache reuse remains separate work.

Failed-stage diagnostics

Terminal failures automatically create FAILURE-LOGS.zip. It includes native reports/logs, nested RESULT.json files, small VCD/FST waveforms and a FAILURE-INDEX.json describing the exact job status, command, included bytes and omissions. Native file bytes are limited to 64 MiB; an oversized log may be a clearly labelled tail. Waveforms larger than 4 MiB remain remote with their path/size/SHA256 in the index. Supply a failure window or seed/timestamp report in the run directory when available. Large waveforms and binary build products are not silently included in the download.

Windows queries using --ssh-runner automatically fetch a failed result's archive when submit/status/cancel returns a terminal failure. The fetch action provides the same explicit operation. --fetch-root before the action overrides the local directory; the default is TEMP/prod2u-thermal/analysis/run-RUN_ID. The adjacent TRANSFER-RECEIPT.json proves archive byte integrity. Archives are not automatically extracted. Repeated queries reuse an identical local archive without retransmitting its chunks. Modified local copies are preserved with a transfer conflict.

The remote job status and exit code remain unchanged. The client adds a separate failure_download result. Query exit3 means that reading the job succeeded but its diagnostic transfer failed; it does not replace the native failure with a new job status. Collection errors are similarly recorded as failure_bundle_error. Old results lacking a diagnostic archive remain unchanged and report UNAVAILABLE. The runner and transfer module must both exist in the exact remote source copy.

On source3afb0f6, an intentional real Icarus failure generated a large full VCD and a small failure window. The native log, window, nested result and Unicode report were downloaded; the full waveform remained remote. Repeated status used zero transferred chunks. Local archive corruption was reported separately while native exit7 remained FAIL, and a fresh download recovered the verified archive. This validates diagnostic collection/transport, not production RTL acceptance.