History Server: collect rotated Ray logs before overwrite - #5101
Open
AdibaAdi wants to merge 8 commits into
Open
History Server: collect rotated Ray logs before overwrite#5101AdibaAdi wants to merge 8 commits into
AdibaAdi wants to merge 8 commits into
Conversation
Drive rotated-log backpressure from bytes retained solely by collector hard links rather than total logical staged bytes, preserving normal Ray rotation while bounding storage-outage retention. Enable production high/low watermarks, reconstruct retained-byte accounting from link counts, refresh ownership during reconciliation, and add regression coverage for shared links, rollover, outage recovery, and restart reconstruction. Also apply final lifecycle comment and test-only inspection cleanups.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 2d45c6f. Configure here.
Use the resolved startup session directory when initial session_latest resolution fails so alternate path spellings cannot be mistaken for a session transition. Add regression coverage proving a transient resolution failure does not relocate the live session or clear its verified node identity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Why are these changes needed?
Ray rotates logs by default to limit local disk usage. The History Server collector previously relied primarily on collecting the remaining Ray log directory during shutdown or recovery from
prev-logs.For long-running workloads, this means an older rotated backup can be overwritten before the collector uploads it, leaving part of the log history unrecoverable even when object storage is available.
This PR adds live rotated-log collection for both head and worker collectors.
When a completed Ray rotation backup appears, the collector preserves its inode with a hard link before Ray can roll it out of the local backup ring. Each captured generation receives a unique
.rotated.<capture-id>name, so successive rotations that reuse filenames such as.1remain distinct.Filesystem notifications provide prompt discovery, with periodic reconciliation as a backstop for missed or coalesced events. Captures are staged on the shared Ray filesystem, uploaded asynchronously, and reconstructed from staging after collector restart.
The upload lifecycle keeps pending and successfully uploaded captures distinct, retries transport failures, avoids duplicate uploads, and preserves the existing non-rotated log collection path.
Session transitions also preserve the session and Ray node identity associated with each capture. Known outgoing sessions are relocated individually before the existing broad leftover sweep, preventing unrelated sessions from being attributed to the same node ID.
To prevent rotated-log staging from growing indefinitely during an object-store outage, backpressure is based on bytes retained solely because the collector owns the final hard link to an inode. Captures that Ray still owns do not count toward this limit. New capture pauses at a 1 GiB high watermark and resumes below 512 MiB while uploads, retries, promotions, and releases continue.
Related issue number
Closes #4830
Labels
doc-updates-requiredlabel.breaking-changelabel.Checks
Validation
The rotated-log package was also exercised repeatedly under the race detector.
Backpressure regression coverage verifies that:
Manual test instructions
I validated the collector and History Server flow locally using a native arm64 Kind cluster, the KubeRay operator, Ray 2.52.0, and MinIO.
For the test, Ray rotation was configured with:
I ran one Ray task pinned to the head node and another pinned to the worker node. Each task emitted 6,400 uniquely marked log lines, producing substantially more rotations than Ray's five-file local backup ring could retain.
Observed results:
This confirms that rotations already overwritten from Ray's local backup ring remained recoverable from object storage.
After deleting the RayCluster, all 50 marked rotated objects remained in MinIO.
Using the archived History Server path, I then verified that:
raylet.outlog could still be listed and downloaded successfullyThe live History Server path continues to proxy Ray's dashboard and therefore exposes Ray's local
.1through.5backup filenames. Once the cluster is archived, the object-storage path exposes the collector's.rotated.<capture-id>objects.Scope of manual validation
These results are from local Kind + MinIO integration testing and are not production cloud-storage validation.
The existing History Server line-oriented download path omits a final trailing newline when serving a log file. Marker content was preserved; this behavior is pre-existing and unrelated to rotated-log capture.