[History Server] Treat suspended RayCluster as dead in isDead #5069
Suspended clusters still treated live
High Severity
<!-- DESCRIPTION START -->isDead now treats a fully suspended RayCluster as dead, but listClusters and resolveSession still treat any existing CR as live. Opening the default Live/latest entry skips LoadSession/isDead and keeps proxying to a head that no longer exists, so the primary UI path for suspended clusters still fails.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: f6636aef-2571-435f-bea8-f2afe594b67d -->
<!-- LOCATIONS START
historyserver/pkg/historyserver/session_processor.go#L96-L99
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjA0MzMyNWI5LWE4OTEtNDdhZC1hNzg2LTZlNWQ5MDUwMzQ1NiIsImVuY3J5cHRpb25LZXkiOiJjNDhZOHRtLXZYTjFUQzJEYjJJQVVrQjl5bC1HSU5fMTZ6NEh5elZQRUprIiwiYnJhbmNoIjoiZml4L2hpc3RvcnlzZXJ2ZXItc3VzcGVuZGVkLXJheWNsdXN0ZXItbGl2ZS1jaGVjayIsInJlcG9Pd25lciI6InJheS1wcm9qZWN0IiwicmVwb05hbWUiOiJrdWJlcmF5In19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjA0MzMyNWI5LWE4OTEtNDdhZC1hNzg2LTZlNWQ5MDUwMzQ1NiIsImVuY3J5cHRpb25LZXkiOiJjNDhZOHRtLXZYTjFUQzJEYjJJQVVrQjl5bC1HSU5fMTZ6NEh5elZQRUprIiwiYnJhbmNoIjoiZml4L2hpc3RvcnlzZXJ2ZXItc3VzcGVuZGVkLXJheWNsdXN0ZXItbGl2ZS1jaGVjayIsInJlcG9Pd25lciI6InJheS1wcm9qZWN0IiwicmVwb05hbWUiOiJrdWJlcmF5IiwicHJOdW1iZXIiOjUwNjksImNvbW1pdFNoYSI6IjdlYjg0N2U4Mjc2YWY3ZTgzMDI2MGUxMDdhMGQ2YzNmOGVkMGRjMDciLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by Cursor Bugbot for commit 7eb847e8276af7e830260e107a0d6c3f8ed0dc07. Configure here.</sup>
<!-- BUGBOT_REVIEW -->
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
<!-- BUGBOT_FIX_ALL -->
<a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTpjYTE4MWIyMi0wNzA5LTQzYTYtODM4Mi1hMjhjYmY3N2U3ZDEiLCJlbmNyeXB0aW9uS2V5IjoiRmMtQlJTMTVBbUJWTVVnWnZFRFp5UjJJT2dJcTQ4QWlvQzJaeldSUWpPVSIsImJyYW5jaCI6ImZpeC9oaXN0b3J5c2VydmVyLXN1c3BlbmRlZC1yYXljbHVzdGVyLWxpdmUtY2hlY2siLCJyZXBvT3duZXIiOiJyYXktcHJvamVjdCIsInJlcG9OYW1lIjoia3ViZXJheSJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
<!-- /BUGBOT_FIX_ALL -->
<sup>Reviewed by Cursor Bugbot for commit 7eb847e8276af7e830260e107a0d6c3f8ed0dc07. Configure here.</sup>
Hi @yjaw, thanks for addressing this issue so quickly! As @chiayi mentioned, we’ll wait until after 1.7 to address this.
Approved these changes.
KunWuLuan
yjaw
Why are these changes needed?
When a RayCluster is suspended (
spec.suspend = true), KubeRay deletes all Pods (including the head Pod) but keeps the RayCluster CR. The history server had multiple places that treated "the RayCluster CR exists" as "the cluster is live," none of which accounted for suspension, so it kept trying to proxy dashboard requests to a head Pod that no longer exists — failing with a DNS lookup error — and neither the live nor the dead session for that cluster could be viewed.SessionProcessor.isDeadOnly checked whether the CR existed. Now also treats a suspended RayCluster as dead so its sessions fall back to reading stored historical data.
We check the
RayClusterSuspendedstatus condition rather thanspec.Suspenddirectly:spec.Suspendflipstruethe instant a user requests suspension, well before Pods are actually deleted. Marking the session dead (and caching its snapshot — dead-session snapshots are cached indefinitely) at that point would race the collector's SIGTERM-triggered flush of the final logs/events, permanently caching an incomplete snapshot.RayClusterSuspendedis only set by the controller once it observes zero running Pods (raycluster_controller.go#L2064-L2083), which is after the flush window has passed. During the briefRayClusterSuspendingtransition, the session is still treated as live and a proxy attempt can transiently fail, butSessionStatusLiveis never cached, so the next request re-checks and resolves automatically — no permanent breakage.listClustersandresolveSessionisDeadalone wasn't sufficient:listClusters(used to build the cluster list) andresolveSession(used to resolve/enter_cluster/...requests, including the default"latest"resolution — the primary path a user hits when opening a cluster) each independently call into the K8s client and treat any existing RayCluster CR as live, bypassingisDeadentirely. A suspended cluster was still shown as a live entry in the list, and entering it still resolved to"live"and proxied to a Pod that no longer exists.Extracted
isRayClusterSuspendedas a shared helper (used byisDeadtoo) and applied it in both places so a suspended cluster is excluded from the live list and falls back to stored session data when resolved.Related issue number
Closes #5062
Labels
doc-updates-requiredlabel.breaking-changelabel.Checks
- [x] Unit tests
- [ ] Manual tests
- [ ] This PR is not tested :(