← Back to Pull requests

[History Server] Treat suspended RayCluster as dead in isDead #5069

Open
yjaw opened this pull request with 138 lines diff across 4 files
View on GitHub
yjaw yjaw commented on Aug 02, 2026 10:06 UTC
Author

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.isDead

Only 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 RayClusterSuspended status condition rather than spec.Suspend directly: spec.Suspend flips true the 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. RayClusterSuspended is 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 brief RayClusterSuspending transition, the session is still treated as live and a proxy attempt can transiently fail, but SessionStatusLive is never cached, so the next request re-checks and resolves automatically — no permanent breakage.

listClusters and resolveSession

isDead alone wasn't sufficient: listClusters (used to build the cluster list) and resolveSession (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, bypassing isDead entirely. 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 isRayClusterSuspended as a shared helper (used by isDead too) 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

  • If this PR has user-facing changes that require documentation updates at release time, I have added the doc-updates-required label.

  • If this PR contains breaking changes, I have added the breaking-change label.
  • Checks

  • I've made sure the tests are passing.

  • Testing Strategy

  • - [x] Unit tests
    - [ ] Manual tests
    - [ ] This PR is not tested :(

    Diff: 138 lines (+131 / -7) across 4 files Reviewer: KunWuLuan Review duration: 173756m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.44) × (1 − Review Confidence (0.81)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.44 · 138 lines diff across 4 files
    0.44
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.75 · 2 substantive comment(s)
    0.75
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    80%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.295
    Real PR Conversation Timeline
    5 items
    cursor[bot] cursor[bot] commented on code on Aug 02, 2026 10:30 UTC
    Code Review
    historyserver/pkg/historyserver/session_processor.go:1
    @@ -93,6 +94,9 @@ func (p *SessionProcessor) isDead(ctx context.Context, session utils.ClusterInfo
     	if err != nil {
     		return false, err
     	}
    +	if meta.IsStatusConditionTrue(rc.Status.Conditions, string(rayv1.RayClusterSuspended)) {
    +		return true, nil
    +	}

    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>&nbsp;<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>

    cursor[bot] cursor[bot] commented on Aug 02, 2026 10:30 UTC
    Reviewer

    <!-- 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>

    win5923 win5923 commented on Aug 03, 2026 06:52 UTC
    Contributor

    Hi @yjaw, thanks for addressing this issue so quickly! As @chiayi mentioned, we’ll wait until after 1.7 to address this.

    KunWuLuan KunWuLuan approved these changes on Aug 04, 2026 03:00 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    yjaw yjaw
    Labels
    risk: low confidence: 80.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.9% (MEDIUM) · Higher = larger blast radius
    43.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 80.5% · Lower = rushed or shallow review
    80.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.6% · Safe to merge
    8.6%