Repository navigation
[Health][Train] Add Health Events and Exporter - #67544
pseudo-rnd-thoughts wants to merge 2 commits into
Conversation
Signed-off-by: Mark Towers <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a health event export framework for Ray, adding the HealthEventBuilder and HealthEventExporter classes to serialize and emit health findings, checker shutdowns, and decisions. It also defines the events_health_event.proto schema and integrates these events into the dashboard aggregator. Feedback on the changes includes adding a safety check for uninitialized Ray nodes to prevent potential AttributeErrors, and dynamically allocating ports in the test suite to avoid conflicts during parallel CI runs.
| if not ray.is_initialized(): | ||
| logger.warning("Ray is not initialized; health events will not be emitted.") | ||
| return | ||
| node = ray._private.worker.global_worker.node |
There was a problem hiding this comment.
Accessing ray._private.worker.global_worker.node directly without checking if it is None can lead to an AttributeError (e.g., in unit tests or during early initialization phases where the node is not yet fully initialized on the worker). Add a guard to return early if node is None.
| node = ray._private.worker.global_worker.node | |
| node = ray._private.worker.global_worker.node | |
| if node is None: | |
| logger.warning("Ray node is not initialized; health events will not be emitted.") | |
| return |
| cluster = ray_start_cluster | ||
| cluster.add_node( | ||
| env_vars={ | ||
| "RAY_DASHBOARD_AGGREGATOR_AGENT_EVENTS_EXPORT_ADDR": f"http://127.0.0.1:{_HEALTH_EVENT_PORT}", |
There was a problem hiding this comment.
Avoid using a hardcoded port (_HEALTH_EVENT_PORT) for the test server, as it can cause port conflicts and test flakiness in parallel CI runs. Instead, leverage the dynamically allocated port from the httpserver fixture by using httpserver.port. You can also remove the custom httpserver_listen_address fixture on lines 22-24 to let the server bind to a random free port automatically.
| "RAY_DASHBOARD_AGGREGATOR_AGENT_EVENTS_EXPORT_ADDR": f"http://127.0.0.1:{_HEALTH_EVENT_PORT}", | |
| "RAY_DASHBOARD_AGGREGATOR_AGENT_EVENTS_EXPORT_ADDR": f"http://127.0.0.1:{httpserver.port}", |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit d6c05e8. Configure here.
liulehui
left a comment
There was a problem hiding this comment.
Can we have some example in the description to illustrate how platform should utilize these information?
| CLUSTER_LIFECYCLE = 4; | ||
| AUTOSCALER = 5; | ||
| JOBS = 6; | ||
| RAY_TRAIN = 7; |
There was a problem hiding this comment.
I feel this list is all for core source,
maybe we should create a oneof saying APP/WOKRLOAD, and ray train is one of the app/workload.
| // "nccl_hang_detector", a probe or evaluator `name`, or "health_manager". | ||
| string checker_name = 1; | ||
| // Strictly increasing per checker instance; orders the events. | ||
| uint64 sequence = 2; |
There was a problem hiding this comment.
if we have the timestamp, do we still need to sequence?
| uint64 sequence = 2; | ||
| // When the observation behind the event was made (e.g. when the poll's | ||
| // `ncclras` query returned). RayEvent.timestamp is when the event was built. | ||
| google.protobuf.Timestamp observed_at = 3; |
There was a problem hiding this comment.
I think RayEvent already has event_id and timestamp?
| } | ||
|
|
||
| // An issue found by a checker. | ||
| message HealthFinding { |
There was a problem hiding this comment.
not sure we want to put state machine in the Proto. what will backend do with this field?
| string finding_id = 1; | ||
| State state = 2; | ||
| // When the underlying issue began (may be earlier than the NEW event). | ||
| google.protobuf.Timestamp started_at = 3; |
There was a problem hiding this comment.
is this duplicated with the observed at?

Description
@liulehui has implemented the first health API classes (probes, evaluators and more) for the REP for Monitoring and Diagnostics. This PR adds the Ray events that export what they find, plus a
HealthEventExporterthat emits new, updated, resolved and stopped findings.TL;DR
This PR adds one exportable
HealthEventto Ray's event pipeline, with three possible bodies: a finding (what a checker saw), a checker-disabled notice (where Ray went blind) and a decision (what Ray did about it). Together they let Anyscale dashboards show a training run's health story end to end, and any future checker plugs in without a new event type or a new Anyscale parser.Motivation
The monitoring and diagnostics REP adds a health API to Ray Train: probes that observe, evaluators that judge, and a HealthManager that acts. Today their output stops at logs. Our first exporter, the NCCL-hang event in #66937, was built for one detector only. Repeating that pattern would mean a new event type and a new Anyscale parser per checker.
This PR replaces it with one generic contract. Any checker built on the health API, including user-written probes and evaluators, gets an export signal for free. That lets Anyscale build one observability dashboard that explains silent hangs, disabled checks and automatic restarts or evictions.
The three bodies
Every
HealthEventshares one envelope (checker_name, a per-checkersequence,observed_at) and carries exactly one body.HealthFindingfinding_id; NEW → UPDATED → RESOLVED or STOPPED; each event is a full snapshotNcclHangFindingdetailsHealthCheckerDisabledchecker_name; one final event, after its open findings are STOPPEDncclrasmissing → DEPENDENCY_UNAVAILABLEHealthDecisiondecision_id; one event; points at thefinding_idsit acts onWhy three bodies, not one
The three are different things with different identities and lifecycles, so merging them would leave most fields meaningless for any one event and make consumers guess.
CheckerDisabled. No findings can mean healthy or blind. A dashboard must tell those apart before anyone trusts a green run.finding_idskeeps the cause-and-effect link without copying finding data.HEALTH_EVENTtype, one aggregator allowlist entry and one ordering key. A new checker adds a typeddetailsmessage, or usescustomfor user checkers, rather than a new event type.Style rules the schema follows:
finding_idis the current state, and a dropped event is harmless.UNSPECIFIED.Status and asks
HealthFinding.RAY_enable_ray_eventon andHEALTH_EVENTlisted inRAY_ENABLE_PYTHON_RAY_EVENT_TYPES.AI assistance (Claude Code) was used to draft this description.